This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Don't close or flush stdio streams on abort
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 8 May 2013 12:12:32 +0200
- Subject: Re: [PATCH] Don't close or flush stdio streams on abort
- References: <mvm4ned3jja dot fsf at hawking dot suse dot de>
On Wed, May 08, 2013 at 11:31:05AM +0200, Andreas Schwab wrote:
> +* The abort function no longer tries to flush or close any stdio streams.
> + Doing so would run into locking problems because abort is required to be
> + async-signal-safe, but fflush and fclose cannot be.
I agree with removal at stage 1.
However removal at stage 4 could cause debugging info not be displayed.
Could it be possible to ignore delivery with something like sigprocmask?
Stopping other threads could be possible but probably an overkill.
Ondra.
> Version 2.17
>
> diff --git a/stdlib/abort.c b/stdlib/abort.c
> index 72b2d60..4b7df18 100644
> --- a/stdlib/abort.c
> +++ b/stdlib/abort.c
> @@ -30,9 +30,6 @@
> # define ABORT_INSTRUCTION
> #endif
>
> -#include <libio/libioP.h>
> -#define fflush(s) _IO_flush_all_lockp (0)
> -
> /* Exported variable to locate abort message in core files etc. */
> struct abort_msg_s *__abort_msg __attribute__ ((nocommon));
> libc_hidden_def (__abort_msg)
> @@ -66,16 +63,8 @@ abort (void)
> __sigprocmask (SIG_UNBLOCK, &sigs, (sigset_t *) NULL);
> }
>
> - /* Flush all streams. We cannot close them now because the user
> - might have registered a handler for SIGABRT. */
> - if (stage == 1)
> - {
> - ++stage;
> - fflush (NULL);
> - }
> -
> /* Send signal which possibly calls a user handler. */
> - if (stage == 2)
> + if (stage == 1)
> {
> /* This stage is special: we must allow repeated calls of
> `abort' when a user defined handler for SIGABRT is installed.
> @@ -93,7 +82,7 @@ abort (void)
> }
>
> /* There was a handler installed. Now remove it. */
> - if (stage == 3)
> + if (stage == 2)
> {
> ++stage;
> memset (&act, '\0', sizeof (struct sigaction));
> @@ -103,30 +92,22 @@ abort (void)
> __sigaction (SIGABRT, &act, NULL);
> }
>
> - /* Now close the streams which also flushes the output the user
> - defined handler might has produced. */
> - if (stage == 4)
> - {
> - ++stage;
> - __fcloseall ();
> - }
> -
> /* Try again. */
> - if (stage == 5)
> + if (stage == 3)
> {
> ++stage;
> raise (SIGABRT);
> }
>
> /* Now try to abort using the system specific command. */
> - if (stage == 6)
> + if (stage == 4)
> {
> ++stage;
> ABORT_INSTRUCTION;
> }
>
> /* If we can't signal ourselves and the abort instruction failed, exit. */
> - if (stage == 7)
> + if (stage == 5)
> {
> ++stage;
> _exit (127);
> --
> 1.8.2.2
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."