Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: ppluzhnikov@google.com (Paul Pluzhnikov)
To: gdb-patches@sourceware.org
Cc: ppluzhnikov@google.com
Subject: [patch] Fix crash in read_dbx_symtab
Date: Fri, 24 Jul 2009 17:25:00 -0000	[thread overview]
Message-ID: <20090724165146.1E87476BC0@localhost> (raw)

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)


             reply	other threads:[~2009-07-24 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24 17:25 Paul Pluzhnikov [this message]
2009-07-29 19:24 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090724165146.1E87476BC0@localhost \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox