aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-04-26 01:53:45 +0000
committerMark Johnston <markj@FreeBSD.org>2026-04-26 01:56:14 +0000
commite3b8e55e710bf355f371d798aa943281007a7ea9 (patch)
treeed294625d5c8e9fdc04563622f29c730707b0303
parenta02d794f5acd12ba3cf1de5c204a8dd56af47edd (diff)
netbsd-tests: Fix the mmap_truncate_signal test
Add a volatile qualifier in the loop which triggers SIGBUS, as otherwise the compiler is smart enough to elide it, replacing it with a check for page != 0. MFC after: 1 week
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
index b62c6299d3c2..5b9685658f65 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
@@ -504,7 +504,7 @@ ATF_TC_BODY(mmap_truncate_signal, tc)
ATF_REQUIRE(signal(SIGSEGV, map_sighandler) != SIG_ERR);
sta = 0;
for (i = 0; i < page; i++)
- sta += map[i];
+ sta += ((volatile char *)map)[i];
/* child never will get this far, but the compiler will
not know, so better use the values calculated to
prevent the access to be optimized out */