On macOS 12, in a testdir of all of gnulib (including the 'abort-debug' module),
the c-stack test hangs, eating CPU time. I have to manually kill it with
"kill -9". The test's output looks like this:

$ ./test-c-stack 1
test-c-stack: program error
Stack trace:
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
test-c-stack: program error
Stack trace:
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
libbacktrace: no debug info in Mach-O executable
test-c-stack: program error
Stack trace:
libbacktrace: no debug info in Mach-O executable
...

This patch fixes it.


2024-11-20  Bruno Haible  <br...@clisp.org>

        c-stack: Avoid a busy-looping test on macOS.
        * lib/c-stack.c: Undefine abort.

diff --git a/lib/c-stack.c b/lib/c-stack.c
index 0e14de9423..8db2417ab1 100644
--- a/lib/c-stack.c
+++ b/lib/c-stack.c
@@ -58,6 +58,10 @@
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
+/* Here we need the original abort() function.  (Printing a stack trace
+   from within a signal handler is not going to work in most cases anyway.)  */
+#undef abort
+
 #if HAVE_STACK_OVERFLOW_RECOVERY
 
 /* Storage for the alternate signal stack.




Reply via email to