This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix crash in read_dbx_symtab
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: gdb-patches at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Fri, 24 Jul 2009 09:51:46 -0700 (PDT)
- Subject: [patch] Fix crash in read_dbx_symtab
Greetings,
This checkin:
2009-03-31 Daniel Jacobowitz <dan@codesourcery.com>
Keith Seitz <keiths@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
PR gdb/6817
* Makefile.in (dbxread.o): Update.
* dbxread.c (read_dbx_symtab): Use cp_canonicalize_string.
...
Introduced an alloca in a loop for each symbol, which causes GDB
to run out of stack and crash when stack is limited (e.g.
'ulimit -s' == 8192) and the executable has a lot of long STABs
(C++ N_LSYMs in my test case).
Here is a proposed fix.
Thanks,
--
Paul Pluzhnikov
2009-07-24 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/6817
* dbxread.c (read_dbx_symtab): Reduce stack use.
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.104
diff -u -p -u -r1.104 dbxread.c
--- dbxread.c 29 Jun 2009 16:48:15 -0000 1.104
+++ dbxread.c 24 Jul 2009 16:39:03 -0000
@@ -1689,7 +1689,7 @@ pos %d"),
sym_name = NULL; /* pacify "gcc -Werror" */
if (psymtab_language == language_cplus)
{
- char *new_name, *name = alloca (p - namestring + 1);
+ char *new_name, *name = xmalloc (p - namestring + 1);
memcpy (name, namestring, p - namestring);
name[p - namestring] = '\0';
new_name = cp_canonicalize_string (name);
@@ -1700,6 +1700,7 @@ pos %d"),
&objfile->objfile_obstack);
xfree (new_name);
}
+ xfree (name);
}
if (sym_len == 0)