]> Savannah Git Hosting - gnulib.git/commitdiff
free tests: Avoid test failure with ASAN.
authorBruno Haible <bruno@clisp.org>
Thu, 9 May 2024 13:06:40 +0000 (15:06 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 17 May 2024 23:11:57 +0000 (01:11 +0200)
* tests/test-free.c (main): Skip mmap/munmap based test if ASAN is
enabled.

ChangeLog
tests/test-free.c

index 26d0153fc50fa05b84ec9ad6f201428be347d216..2201d9163aea9bb55a7d5980d46eb8d63dfce6e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-09  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        explicit_bzero, memset_explicit tests: Avoid test failures with ASAN.
index 703c550e0d713d830ba66d1d4bf2d2cc2a0a47ec..9cc0c7016c9217a206a6a57c09d2d24de7189661 100644 (file)
@@ -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;
 }