PATCH: gas --statistics segfault
Alan Modra
amodra@bigpond.net.au
Tue Feb 21 10:19:00 GMT 2006
On Thu, Feb 09, 2006 at 09:38:13AM +1030, Alan Modra wrote:
> On Tue, Feb 07, 2006 at 10:13:55AM -0800, H. J. Lu wrote:
> > * as.c (close_output_file): New.
> > (main): Register close_output_file with xatexit before
> > dump_statistics. Don't call output_file_close.
>
> OK, thanks!
Small problem. If we abort inside output_file_close, as can happen when
writing relocs (found running gas testsuite with xscale-coff target),
then close_output_file gets called again recursively until we run out of
memory. I started fixing this by guarding against recursion in
close_output_file, then decided that the real bug is in _bfd_abort. We
shouldn't run xatexit registered functions on an abort.
* bfd.c: (_bfd_default_error_handler): Don't call abort on
error, instead call _exit.
(_bfd_abort): Call _exit not xexit.
Index: bfd/bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.79
diff -u -p -r1.79 bfd.c
--- bfd/bfd.c 7 Dec 2005 14:43:53 -0000 1.79
+++ bfd/bfd.c 21 Feb 2006 00:01:41 -0000
@@ -216,6 +216,11 @@ CODE_FRAGMENT
#include "libecoff.h"
#undef obj_symbols
#include "elf-bfd.h"
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
/* provide storage for subsystem, stack and heap data which may have been
passed in on the command line. Ld puts this data into a bfd_link_info
@@ -437,7 +442,7 @@ _bfd_default_error_handler (const char *
/* Reserve enough space for the existing format string. */
avail -= strlen (fmt) + 1;
if (avail > 1000)
- abort ();
+ _exit (EXIT_FAILURE);
p = fmt;
while (1)
@@ -775,10 +780,6 @@ bfd_assert (const char *file, int line)
/* A more or less friendly abort message. In libbfd.h abort is
defined to call this function. */
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
-
void
_bfd_abort (const char *file, int line, const char *fn)
{
@@ -791,7 +792,7 @@ _bfd_abort (const char *file, int line,
(_("BFD %s internal error, aborting at %s line %d\n"),
BFD_VERSION_STRING, file, line);
(*_bfd_error_handler) (_("Please report this bug.\n"));
- xexit (EXIT_FAILURE);
+ _exit (EXIT_FAILURE);
}
/*
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list