git: 938915a22c84 - main - netbsd-tests: Fix regcomp_too_big flakiness
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Jan 2026 21:13:43 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=938915a22c84af88afa587694e8d63ce9dd202f4
commit 938915a22c84af88afa587694e8d63ce9dd202f4
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-01-27 21:08:35 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-01-27 21:08:35 +0000
netbsd-tests: Fix regcomp_too_big flakiness
The test sometimes crashes with ASLR enabled. This seems to happen when
regcomp() grows the process stack and happens to run into the virtual
memory limit set at the beginning of the test. ASLR triggers the
problem since it introduces a bit of fragmentation and thus introduces
cases where stack allocation can be the trigger of virtual memory
exhaustion, rather than dynamic memory allocation in regcomp().
Make the test stable by priming the stack before doing anything else.
This effectively reserves 16MB of virtual memory for the stack, which in
practice is enough to make the test stable on amd64.
PR: 259971
Reviewed by: ngie, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54880
---
contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
index 2f3d1025536b..9741f3311ae0 100644
--- a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
+++ b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
@@ -168,6 +168,14 @@ static const struct {
{ p6, REG_BASIC },
};
+static void __noinline
+prime_stack(void)
+{
+ char buf[16 * 1024 * 1024];
+
+ explicit_bzero(buf, sizeof(buf));
+}
+
ATF_TC(regcomp_too_big);
ATF_TC_HEAD(regcomp_too_big, tc)
@@ -186,12 +194,15 @@ ATF_TC_BODY(regcomp_too_big, tc)
int e;
struct rlimit limit;
- if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
- atf_tc_skip("https://bugs.freebsd.org/259971");
-
limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024;
ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1);
+ /*
+ * Pre-fault the stack to avoid crashes caused by growing the stack
+ * beyond the limit.
+ */
+ prime_stack();
+
for (size_t i = 0; i < __arraycount(tests); i++) {
char *d = (*tests[i].pattern)(REGEX_MAXSIZE);
e = regcomp(&re, d, tests[i].type);