diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-06-15 16:17:09 -0700 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-06-15 16:17:09 -0700 |
commit | 48dcd0ba84c5a0fa08a0bd000b24af07d20dce44 (patch) | |
tree | 846d0d74f1e00584a5973bb3eec4ee414314f436 /assert | |
parent | 6355c99740c91ed5a7fa14e378f74950e09f5f48 (diff) | |
download | glibc-48dcd0ba84c5a0fa08a0bd000b24af07d20dce44.tar glibc-48dcd0ba84c5a0fa08a0bd000b24af07d20dce44.tar.gz glibc-48dcd0ba84c5a0fa08a0bd000b24af07d20dce44.tar.bz2 glibc-48dcd0ba84c5a0fa08a0bd000b24af07d20dce44.zip |
Preserve message printed before abort.
The terminal output etc is not visible in a core file. The new
libc-internal variable __abort_msg will point to a string with the
message which has been printed before the abort in case abort is
called from inside libc. BZ #10217
Diffstat (limited to 'assert')
-rw-r--r-- | assert/assert-perr.c | 10 | ||||
-rw-r--r-- | assert/assert.c | 11 |
2 files changed, 13 insertions, 8 deletions
diff --git a/assert/assert-perr.c b/assert/assert-perr.c index dd54246360..f239fab86b 100644 --- a/assert/assert-perr.c +++ b/assert/assert-perr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-1998,2001,2002,2005 Free Software Foundation, Inc. +/* Copyright (C) 1994-1998,2001,2002,2005,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,6 +17,7 @@ 02111-1307 USA. */ #include <assert.h> +#include <atomic.h> #include <libintl.h> #include <stdio.h> #include <stdlib.h> @@ -64,9 +65,10 @@ __assert_perror_fail (int errnum, (void) __fxprintf (NULL, "%s", buf); (void) fflush (stderr); - /* We have to free the buffer since the appplication might catch the - SIGABRT. */ - free (buf); + /* We have to free the old buffer since the application might + catch the SIGABRT signal. */ + char *old = atomic_exchange_acq (&__abort_msg, buf); + free (old); } else { diff --git a/assert/assert.c b/assert/assert.c index 0ef4ca62e4..727fb1446c 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1994-1996,1998,2001,2002,2005 +/* Copyright (C) 1991,1994-1996,1998,2001,2002,2005,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include <assert.h> +#include <atomic.h> #include <libintl.h> #include <stdio.h> #include <stdlib.h> @@ -43,6 +44,7 @@ extern const char *__progname; # include FATAL_PREPARE_INCLUDE #endif + #undef __assert_fail void __assert_fail (const char *assertion, const char *file, unsigned int line, @@ -64,9 +66,10 @@ __assert_fail (const char *assertion, const char *file, unsigned int line, (void) __fxprintf (NULL, "%s", buf); (void) fflush (stderr); - /* We have to free the buffer since the application might catch the - SIGABRT. */ - free (buf); + /* We have to free the old buffer since the application might + catch the SIGABRT signal. */ + char *old = atomic_exchange_acq (&__abort_msg, buf); + free (old); } else { |