]> Savannah Git Hosting - gnulib.git/commitdiff
sigsegv, c-stack tests: Avoid test failures with ASAN.
authorBruno Haible <bruno@clisp.org>
Wed, 8 May 2024 23:41:52 +0000 (01:41 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 17 May 2024 23:01:01 +0000 (01:01 +0200)
* tests/test-sigsegv-catch-stackoverflow1.c
(HAVE_STACK_OVERFLOW_RECOVERY): Undefine if ASAN is enabled.
* tests/test-sigsegv-catch-stackoverflow2.c
(HAVE_STACK_OVERFLOW_RECOVERY): Likewise.
* tests/test-c-stack.c (main): Skip the test if ASAN is enabled.

ChangeLog
tests/test-c-stack.c
tests/test-sigsegv-catch-stackoverflow1.c
tests/test-sigsegv-catch-stackoverflow2.c

index 0bb947cbcd6fd31ec88f6b2e27ef4af26c0810d8..edc5e65949a28dd0125105a4ae0f87f048207f4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-05-08  Bruno Haible  <bruno@clisp.org>
+
+       sigsegv, c-stack tests: Avoid test failures with ASAN.
+       * tests/test-sigsegv-catch-stackoverflow1.c
+       (HAVE_STACK_OVERFLOW_RECOVERY): Undefine if ASAN is enabled.
+       * tests/test-sigsegv-catch-stackoverflow2.c
+       (HAVE_STACK_OVERFLOW_RECOVERY): Likewise.
+       * tests/test-c-stack.c (main): Skip the test if ASAN is enabled.
+
 2024-05-08  Bruno Haible  <bruno@clisp.org>
 
        argp: Fix test failure with clang's ASAN.
index b5ab33309edb6a5fad26132d77acbc9e3490d1b4..d21b8dad7beb42f5803a5a07058bf0640a255e4d 100644 (file)
 
 #include "macros.h"
 
+/* Skip this test when an address sanitizer is in use.  */
+#ifndef __has_feature
+# define __has_feature(a) 0
+#endif
+#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+
+int
+main (int argc, char **argv)
+{
+  fputs ("skipping test: address sanitizer in use\n", stderr);
+  return 77;
+}
+
+#else
+
 static volatile int *
 recurse_1 (volatile int n, volatile int *p)
 {
@@ -48,7 +63,7 @@ recurse (volatile int n)
 int
 main (int argc, char **argv)
 {
-#if HAVE_SETRLIMIT && defined RLIMIT_STACK
+# if HAVE_SETRLIMIT && defined RLIMIT_STACK
   /* Before starting the endless recursion, try to be friendly to the
      user's machine.  On some Linux 2.2.x systems, there is no stack
      limit for user processes at all.  We don't want to kill such
@@ -56,7 +71,7 @@ main (int argc, char **argv)
   struct rlimit rl;
   rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */
   setrlimit (RLIMIT_STACK, &rl);
-#endif
+# endif
 
   if (c_stack_action (NULL) == 0)
     {
@@ -71,3 +86,5 @@ main (int argc, char **argv)
   perror ("c_stack_action");
   return 77;
 }
+
+#endif
index 46b120686c99ace589fbc63f85ef8ffa5e3709d8..7e58bbb762bb8c549f6e82db3fc86074eddd3be2 100644 (file)
 #include <stdio.h>
 #include <limits.h>
 
+/* Skip this test when an address sanitizer is in use.  */
+#ifndef __has_feature
+# define __has_feature(a) 0
+#endif
+#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+# undef HAVE_STACK_OVERFLOW_RECOVERY
+#endif
+
 #if HAVE_STACK_OVERFLOW_RECOVERY
 
 # if defined _WIN32 && !defined __CYGWIN__
index 5113ba5f42c0b657c121fd6f37030e6979c8e49d..60f7eb0cfbcac43a6fb361b38e126f0150467ab8 100644 (file)
 #include <stdio.h>
 #include <limits.h>
 
+/* Skip this test when an address sanitizer is in use.  */
+#ifndef __has_feature
+# define __has_feature(a) 0
+#endif
+#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+# undef HAVE_STACK_OVERFLOW_RECOVERY
+#endif
+
 #if HAVE_STACK_OVERFLOW_RECOVERY && HAVE_SIGSEGV_RECOVERY
 
 # if defined _WIN32 && !defined __CYGWIN__