From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: sigsegv, c-stack tests: Avoid test failures with ASAN
Date: Thu, 09 May 2024 01:44:57 +0200 [thread overview]
Message-ID: <5946940.hTDNKPQEx9@nimes> (raw)
With the clang 17 address sanitizer, I see these 4 test failures:
FAIL: test-c-stack.sh
=====================
FAIL test-c-stack.sh (exit status: 1)
FAIL: test-c-stack2.sh
======================
FAIL test-c-stack2.sh (exit status: 1)
FAIL: test-sigsegv-catch-stackoverflow1
=======================================
FAIL test-sigsegv-catch-stackoverflow1 (exit status: 139)
FAIL: test-sigsegv-catch-stackoverflow2
=======================================
FAIL test-sigsegv-catch-stackoverflow2 (exit status: 139)
This patch avoids the test failures by skipping the tests.
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.
diff --git a/tests/test-c-stack.c b/tests/test-c-stack.c
index b5ab33309e..d21b8dad7b 100644
--- a/tests/test-c-stack.c
+++ b/tests/test-c-stack.c
@@ -30,6 +30,21 @@
#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
diff --git a/tests/test-sigsegv-catch-stackoverflow1.c b/tests/test-sigsegv-catch-stackoverflow1.c
index 46b120686c..7e58bbb762 100644
--- a/tests/test-sigsegv-catch-stackoverflow1.c
+++ b/tests/test-sigsegv-catch-stackoverflow1.c
@@ -24,6 +24,14 @@
#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__
diff --git a/tests/test-sigsegv-catch-stackoverflow2.c b/tests/test-sigsegv-catch-stackoverflow2.c
index 5113ba5f42..60f7eb0cfb 100644
--- a/tests/test-sigsegv-catch-stackoverflow2.c
+++ b/tests/test-sigsegv-catch-stackoverflow2.c
@@ -25,6 +25,14 @@
#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__
reply other threads:[~2024-05-08 23:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5946940.hTDNKPQEx9@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).