As reported by lwhsu and mw on -current lib.libc.regex.exhaust_test.regcomp_too_big fails after ASLR was enabled by default https://ci.freebsd.org/job/FreeBSD-main-amd64-test/19867/testReport/junit/lib.libregex/exhaust_test/regcomp_too_big/ Process with PID 3322 exited with signal 11 and dumped core; attempting to gather stack trace [New LWP 101363] Core was generated by `/usr/tests/lib/libregex/exhaust_test -vallow_sysctl_side_effects -vcam_test_devi'. Program terminated with signal SIGSEGV, Segmentation fault. Invalid permissions for mapped object. #0 0x00001b476990418c in p_ere_exp (p=0x7fffffda1fc0, bc=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:418 418 /usr/src/lib/libc/regex/regcomp.c: No such file or directory. #0 0x00001b476990418c in p_ere_exp (p=0x7fffffda1fc0, bc=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:418 #1 0x00001b47699062eb in p_re (p=p@entry=0x7fffffda1fc0, end1=end1@entry=41, end2=end2@entry=-130) at /usr/src/lib/libc/regex/regcomp.c:783 #2 0x00001b4769904681 in p_ere_exp (p=<optimized out>, bc=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:427 #3 0x00001b47699062eb in p_re (p=p@entry=0x7fffffda1fc0, end1=end1@entry=41, end2=end2@entry=-130) at /usr/src/lib/libc/regex/regcomp.c:783 #4 0x00001b4769904681 in p_ere_exp (p=<optimized out>, bc=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:427 ... #18796 0x00001b4769904681 in p_ere_exp (p=<optimized out>, bc=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:427 #18797 0x00001b47699062eb in p_re (p=p@entry=0x7fffffda1fc0, end1=end1@entry=-129, end2=end2@entry=-129) at /usr/src/lib/libc/regex/regcomp.c:783 #18798 0x00001b47699033e0 in regcomp_internal (cflags=1750826696, pflags=0, preg=<optimized out>, pattern=<optimized out>) at /usr/src/lib/libc/regex/regcomp.c:318 #18799 regcomp (preg=0x7fffffda21a0, pattern=0x1b476ac3e480 "(.?)(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}(.\\{0,}"..., cflags=1) at /usr/src/lib/libc/regex/regcomp.c:371 #18800 0x00001b3f67584600 in ?? () #18801 0x00001b4767ed3057 in atf_tc_run (tc=0x1b3f67587bb8, tc@entry=0x1b476abee020, resfile=<optimized out>, resfile@entry=0x1 <error: Cannot access memory at address 0x1>) at /usr/src/contrib/atf/atf-c/tc.c:1054 #18802 0x00001b4767ed516e in atf_tp_run (tp=tp@entry=0x7fffffda2a78, tcname=tcname@entry=0x1b476abee020 "regcomp_too_big", resfile=<optimized out>) at /usr/src/contrib/atf/atf-c/tp.c:201 #18803 0x00001b4767ed5b63 in run_tc (tp=0x7fffffda2a78, p=0x7fffffda2a90, exitcode=<optimized out>) at /usr/src/contrib/atf/atf-c/detail/tp_main.c:504 #18804 controlled_main (argc=<optimized out>, argv=0x7fffffda3b38, add_tcs_hook=0x1b3f67584450, exitcode=<optimized out>) at /usr/src/contrib/atf/atf-c/detail/tp_main.c:574 #18805 atf_tp_main (argc=<optimized out>, argv=0x7fffffda3b38, add_tcs_hook=0x1b3f67584450) at /usr/src/contrib/atf/atf-c/detail/tp_main.c:604 #18806 0x00001b3f6758421d in ?? () #18807 0x0000000000000000 in ?? () GDB exited successfully Files left in work directory after failure: exhaust_test.core
Source reference: contrib/netbsd-tests/lib/libc/regex/t_exhaust.c This test is already disabled by default in CI on i386 (PR237450), with a note "It seems that the tests are exhausting memory on i386 now."
It did not fail in the most recent run; I suspect the test is going to pass/fail intermittently. Given the experience on i386 we probably need to reconsider the way this test is implemented. https://ci.freebsd.org/job/FreeBSD-main-amd64-test/19869/#showFailuresLink
Created attachment 264260 [details] [PATCH] regex/exhaust_test: skip flaky 'regcomp_too_big' testcase on all archs This bug is still relevant and is failing on amd64 as seen here: https://ci.freebsd.org/view/Test/job/FreeBSD-main-amd64-test/26868/testReport/lib.libc.regex/exhaust_test/regcomp_too_big/ I confirmed that it intermittently fails locally with the following command (using 100 runs because it does pass the first few runs). $ bricoler run freebsd-src-regression-suite --param freebsd-src:url=/usr/src --param freebsd-src:branch= --param freebsd-src-regression-suite:hypervisor=bhyve --param freebsd-src-regression-suite:memory=4096 --param freebsd-src-regression-suite:ncpus=2 --param freebsd-src-regression-suite:parallelism=1 --param freebsd-src-regression-suite:count=100 --param freebsd-src-regression-suite:tests='lib/libc/regex/exhaust_test:regcomp_too_big' I've attached a patch to skip this testcase against this PR for tracking. NOTE to future triagers: do not close this bug until the test is fixed and unskipped.
Can we get this patch submitted to help get CI clean in the meantime?
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1ddff51060ad759e35dcc4716b0bdcdb40255862 commit 1ddff51060ad759e35dcc4716b0bdcdb40255862 Author: Siva Mahadevan <me@svmhdvn.name> AuthorDate: 2025-10-03 13:56:32 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-17 14:24:01 +0000 regex/exhaust_test: Skip flaky 'regcomp_too_big' testcase on all archs PR: 259971 Signed-off-by: Siva Mahadevan <me@svmhdvn.name> Sponsored by: The FreeBSD Foundation contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
One curiosity, this test has atf_tc_set_md_var(tc, "require.memory", "64M"); but then does limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024; ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1);
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=08345e62a28eb971f65125f45c512a12b39ee2eb commit 08345e62a28eb971f65125f45c512a12b39ee2eb Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-10-17 14:43:25 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-17 14:45:11 +0000 regex/exhaust_test: Update require.memory PR: 259971 Obtained from: NetBSD 7753bf0b705a Sponsored by: The FreeBSD Foundation contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Thanks! Please MFC to stable/15 whenever possible, as the test fails there intermittently: https://ci.freebsd.org/view/Test/job/FreeBSD-stable-15-amd64-test/85/testReport/lib.libc.regex/exhaust_test/regcomp_too_big/
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=da457e5c856d26d41e9a30a08d0087937d28a41f commit da457e5c856d26d41e9a30a08d0087937d28a41f Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-10-17 14:43:25 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-20 18:22:37 +0000 regex/exhaust_test: Update require.memory PR: 259971 Obtained from: NetBSD 7753bf0b705a Sponsored by: The FreeBSD Foundation (cherry picked from commit 08345e62a28eb971f65125f45c512a12b39ee2eb) contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=47ea2e9edf787044eff1bda533cb74758631250b commit 47ea2e9edf787044eff1bda533cb74758631250b Author: Siva Mahadevan <me@svmhdvn.name> AuthorDate: 2025-10-03 13:56:32 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-20 18:22:37 +0000 regex/exhaust_test: Skip flaky 'regcomp_too_big' testcase on all archs PR: 259971 Signed-off-by: Siva Mahadevan <me@svmhdvn.name> Sponsored by: The FreeBSD Foundation (cherry picked from commit 1ddff51060ad759e35dcc4716b0bdcdb40255862) contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
A commit in branch main references this bug: 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(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d17e192524a62801e3ca52ead3716be6c7c22531 commit d17e192524a62801e3ca52ead3716be6c7c22531 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-01-27 21:08:35 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-02-09 18:03:41 +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 (cherry picked from commit 938915a22c84af88afa587694e8d63ce9dd202f4) contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)