mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
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
This commit is contained in:
parent
6355c99740
commit
48dcd0ba84
11
ChangeLog
11
ChangeLog
@ -1,5 +1,16 @@
|
||||
2009-06-15 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
[BZ #10217]
|
||||
* stdlib/abort.c: Define variable __abort_msg.
|
||||
* stdlib/Versions: Export __abort_msg with GLIBC_PRIVATE version.
|
||||
* include/stdlib.h: Declare __abort_msg.
|
||||
* assert/assert-perr.c: Don't free buffer for message immediately.
|
||||
Store atomically in __abort_msg and free old buffer if necessary.
|
||||
* assert/assert.c: Likewise.
|
||||
* sysdeps/posix/libc_fatal.c: Allocate buffer for message, copy it,
|
||||
store pointer in __abort_msg, and possibly free old string.
|
||||
* sysdeps/unix/sysv/linux/libc_fatal.c: Likewise.
|
||||
|
||||
* time/tzfile.c (__tzfile_read): Correct computation of tzspec_len.
|
||||
|
||||
[BZ #10211]
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -221,6 +221,9 @@ extern int __qfcvt_r (long double __value, int __ndigit,
|
||||
extern void *__default_morecore (ptrdiff_t) __THROW;
|
||||
libc_hidden_proto (__default_morecore)
|
||||
|
||||
extern char *__abort_msg;
|
||||
libc_hidden_proto (__abort_msg)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#undef __Need_M_And_C
|
||||
|
@ -104,5 +104,7 @@ libc {
|
||||
# functions which have an additional interface since they are
|
||||
# are cancelable.
|
||||
__libc_system;
|
||||
# Variable which needs a dynamic symbol table entry.
|
||||
__abort_msg;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991,93,95,96,97,98,2001,02 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991,93,1995-1998,2001,02,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
|
||||
@ -36,6 +36,10 @@
|
||||
# define fflush(s) _IO_flush_all_lockp (0)
|
||||
#endif
|
||||
|
||||
/* Exported variable to locate abort message in core files etc. */
|
||||
char *__abort_msg __attribute__ ((nocommon));
|
||||
libc_hidden_def (__abort_msg)
|
||||
|
||||
/* We must avoid to run in circles. Therefore we remember how far we
|
||||
already got. */
|
||||
static int stage;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user