From: Bruno Haible Date: Thu, 18 Jul 2024 20:40:07 +0000 (+0200) Subject: abort-debug: Document better. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c8890abcb08693a1e524526d3a9b9d83a10cec38;p=gnulib.git abort-debug: Document better. Suggested by Paul Eggert in . * lib/stdlib.in.h (abort): Add comment. * doc/stack-trace.texi: Document what to do in signal handlers. --- diff --git a/ChangeLog b/ChangeLog index ee73f00cc8..d1a64b6877 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-07-18 Bruno Haible + + abort-debug: Document better. + Suggested by Paul Eggert in + . + * lib/stdlib.in.h (abort): Add comment. + * doc/stack-trace.texi: Document what to do in signal handlers. + 2024-07-18 Alejandro Colomar xstrtol: Strengthen sanity check. diff --git a/doc/stack-trace.texi b/doc/stack-trace.texi index e7fc453d88..1b266c0cbd 100644 --- a/doc/stack-trace.texi +++ b/doc/stack-trace.texi @@ -65,3 +65,9 @@ it prints the stack trace of the current thread, before actually aborting. Thus, @code{abort ()} remains the idiom of choice for signaling a fatal situation that requires developer attention: it is useful both in debugging environments and production code. + +Note: +While the original @code{abort} function is safe to call in signal handlers, +the overridden @code{abort} function is not. +In signal handlers, you will need to call the original @code{abort} function, +by doing @code{#undef abort} first. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 7c6daa58b8..d86b3ad53c 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -241,6 +241,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " #if @GNULIB_ABORT_DEBUG@ +/* Terminates the current process with signal SIGABRT. + Note: While the original abort() function is safe to call in signal handlers, + the overridden abort() function is not. */ # if @REPLACE_ABORT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef abort