summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-06-15 16:17:09 -0700
committerUlrich Drepper <drepper@redhat.com>2009-06-15 16:17:09 -0700
commit48dcd0ba84c5a0fa08a0bd000b24af07d20dce44 (patch)
tree846d0d74f1e00584a5973bb3eec4ee414314f436 /sysdeps
parent6355c99740c91ed5a7fa14e378f74950e09f5f48 (diff)
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 'sysdeps')
-rw-r--r--sysdeps/posix/libc_fatal.c17
-rw-r--r--sysdeps/unix/sysv/linux/libc_fatal.c18
2 files changed, 33 insertions, 2 deletions
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
index c611b84363..4f11c0fcb0 100644
--- a/sysdeps/posix/libc_fatal.c
+++ b/sysdeps/posix/libc_fatal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1994,1995,1997,2000,2004,2005
+/* Copyright (C) 1993-1995,1997,2000,2004,2005,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -17,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <atomic.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
@@ -123,6 +124,20 @@ __libc_message (int do_abort, const char *fmt, ...)
if (TEMP_FAILURE_RETRY (__writev (fd, iov, nlist)) == total)
written = true;
+
+ char *buf = do_abort ? malloc (total + 1) : NULL;
+ if (buf != NULL)
+ {
+ char *wp = buf;
+ for (int cnt = 0; cnt < nlist; ++cnt)
+ wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
+ *wp = '\0';
+
+ /* 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);
+ }
}
va_end (ap);
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index c7fac6ab51..7287f4ef6c 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1993-1995,1997,2000,2002-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1993-1995,1997,2000,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
@@ -16,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <atomic.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
@@ -131,6 +133,20 @@ __libc_message (int do_abort, const char *fmt, ...)
if (cnt == total)
written = true;
+
+ char *buf = do_abort ? malloc (total + 1) : NULL;
+ if (buf != NULL)
+ {
+ char *wp = buf;
+ for (int cnt = 0; cnt < nlist; ++cnt)
+ wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
+ *wp = '\0';
+
+ /* 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);
+ }
}
va_end (ap);