mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03: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:
11
ChangeLog
11
ChangeLog
@ -1,5 +1,16 @@
|
|||||||
2009-06-15 Ulrich Drepper <drepper@redhat.com>
|
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.
|
* time/tzfile.c (__tzfile_read): Correct computation of tzspec_len.
|
||||||
|
|
||||||
[BZ #10211]
|
[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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -17,6 +17,7 @@
|
|||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <atomic.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -64,9 +65,10 @@ __assert_perror_fail (int errnum,
|
|||||||
(void) __fxprintf (NULL, "%s", buf);
|
(void) __fxprintf (NULL, "%s", buf);
|
||||||
(void) fflush (stderr);
|
(void) fflush (stderr);
|
||||||
|
|
||||||
/* We have to free the buffer since the appplication might catch the
|
/* We have to free the old buffer since the application might
|
||||||
SIGABRT. */
|
catch the SIGABRT signal. */
|
||||||
free (buf);
|
char *old = atomic_exchange_acq (&__abort_msg, buf);
|
||||||
|
free (old);
|
||||||
}
|
}
|
||||||
else
|
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.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@ -18,6 +18,7 @@
|
|||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <atomic.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -43,6 +44,7 @@ extern const char *__progname;
|
|||||||
# include FATAL_PREPARE_INCLUDE
|
# include FATAL_PREPARE_INCLUDE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#undef __assert_fail
|
#undef __assert_fail
|
||||||
void
|
void
|
||||||
__assert_fail (const char *assertion, const char *file, unsigned int line,
|
__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) __fxprintf (NULL, "%s", buf);
|
||||||
(void) fflush (stderr);
|
(void) fflush (stderr);
|
||||||
|
|
||||||
/* We have to free the buffer since the application might catch the
|
/* We have to free the old buffer since the application might
|
||||||
SIGABRT. */
|
catch the SIGABRT signal. */
|
||||||
free (buf);
|
char *old = atomic_exchange_acq (&__abort_msg, buf);
|
||||||
|
free (old);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -221,6 +221,9 @@ extern int __qfcvt_r (long double __value, int __ndigit,
|
|||||||
extern void *__default_morecore (ptrdiff_t) __THROW;
|
extern void *__default_morecore (ptrdiff_t) __THROW;
|
||||||
libc_hidden_proto (__default_morecore)
|
libc_hidden_proto (__default_morecore)
|
||||||
|
|
||||||
|
extern char *__abort_msg;
|
||||||
|
libc_hidden_proto (__abort_msg)
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#undef __Need_M_And_C
|
#undef __Need_M_And_C
|
||||||
|
@ -104,5 +104,7 @@ libc {
|
|||||||
# functions which have an additional interface since they are
|
# functions which have an additional interface since they are
|
||||||
# are cancelable.
|
# are cancelable.
|
||||||
__libc_system;
|
__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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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)
|
# define fflush(s) _IO_flush_all_lockp (0)
|
||||||
#endif
|
#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
|
/* We must avoid to run in circles. Therefore we remember how far we
|
||||||
already got. */
|
already got. */
|
||||||
static int stage;
|
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.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <atomic.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <paths.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)
|
if (TEMP_FAILURE_RETRY (__writev (fd, iov, nlist)) == total)
|
||||||
written = true;
|
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);
|
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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <atomic.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
@ -131,6 +133,20 @@ __libc_message (int do_abort, const char *fmt, ...)
|
|||||||
|
|
||||||
if (cnt == total)
|
if (cnt == total)
|
||||||
written = true;
|
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);
|
va_end (ap);
|
||||||
|
Reference in New Issue
Block a user