Similarly, the clang 17 ASAN reports the 'test-free' test: ================================================================= ==2069723==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f8a90324000 at pc 0x55c1bfe66a3a bp 0x7ffdd392c9d0 sp 0x7ffdd392c190 READ of size 4096 at 0x7f8a90324000 thread T0 #0 0x55c1bfe66a39 in __asan_memcpy /home/runner/work/llvm-project/llvm-project/final/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:63:3 #1 0x55c1bfea6e6b in main /media/develdata/devel/GNULIB/testdir-all/build-64-clang/gltests/../../gltests/test-free.c:141:11 #2 0x7f8a97bfcd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #3 0x7f8a97bfce3f in __libc_start_main csu/../csu/libc-start.c:392:3 #4 0x55c1bfdcb304 in _start (/media/develdata/devel/GNULIB/testdir-all/build-64-clang/gltests/test-free+0x2c304)
0x7f8a90324000 is located 2048 bytes before 16776960-byte region [0x7f8a90324800,0x7f8a91324700) allocated by thread T0 here: #0 0x55c1bfe6897e in malloc /home/runner/work/llvm-project/llvm-project/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3 #1 0x55c1bfea6d62 in main /media/develdata/devel/GNULIB/testdir-all/build-64-clang/gltests/../../gltests/test-free.c:135:33 #2 0x7f8a97bfcd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 SUMMARY: AddressSanitizer: heap-buffer-overflow /home/runner/work/llvm-project/llvm-project/final/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:63:3 in __asan_memcpy Shadow bytes around the buggy address: 0x7f8a90323d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90323e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90323e80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90323f00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90323f80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x7f8a90324000:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90324080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90324100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90324180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90324200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x7f8a90324280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==2069723==ABORTING FAIL test-free (exit status: 134) The cause: this test assumes glibc malloc(), not some ASAN wrappers. 2024-05-09 Bruno Haible <br...@clisp.org> free tests: Avoid test failure with ASAN. * tests/test-free.c (main): Skip mmap/munmap based test if ASAN is enabled. 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; }