From: Bruno Haible Date: Thu, 9 May 2024 13:06:40 +0000 (+0200) Subject: free tests: Avoid test failure with ASAN. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=6e688447da62dd45d7bbcffe36b0e2905dcb6507;p=gnulib.git free tests: Avoid test failure with ASAN. * tests/test-free.c (main): Skip mmap/munmap based test if ASAN is enabled. --- diff --git a/ChangeLog b/ChangeLog index 26d0153fc5..2201d9163a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-05-09 Bruno Haible + + free tests: Avoid test failure with ASAN. + * tests/test-free.c (main): Skip mmap/munmap based test if ASAN is + enabled. + 2024-05-09 Bruno Haible explicit_bzero, memset_explicit tests: Avoid test failures with ASAN. diff --git a/tests/test-free.c b/tests/test-free.c index 703c550e0d..9cc0c7016c 100644 --- a/tests/test-free.c +++ b/tests/test-free.c @@ -98,6 +98,12 @@ main () #undef N } + /* Skip this test when an address sanitizer is in use, because it would report + a "heap buffer overflow". */ + #ifndef __has_feature + #define __has_feature(a) 0 + #endif + #if !(defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)) /* Test a less common code path. When malloc() is based on mmap(), free() can sometimes call munmap(). munmap() usually succeeds, but fails in a particular situation: when @@ -170,6 +176,7 @@ main () } } #endif + #endif return 0; }