Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: nickc@redhat.com
Subject: [PATCH] Fix copy of filename in bfd's filename field
Date: Fri, 03 Jan 2014 12:59:00 -0000	[thread overview]
Message-ID: <1388753936-2835-1-git-send-email-emachado@linux.vnet.ibm.com> (raw)

Hi,

in my recent tests, upstream gdb was crashing with the following:

$ ./gdb ./testsuite/gdb.base/break -q -ex run
Reading symbols from ./testsuite/gdb.base/break...done.
Starting program:
/home/emachado/devel/gdb/binutils-gdb.git/build/gdb/testsuite/gdb.base/break 
*** glibc detected *** ./gdb: double free or corruption (out): 0x088efc80 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb72c9ee2]
./gdb[0x83583e9]
./gdb(bfd_close+0x99)[0x8358c81]
./gdb[0x821ba50]
...

It was caused by this commit 1be509 on binutils code
(https://sourceware.org/ml/binutils-cvs/2014-01/msg00003.html)
which is now using xstrdup to store a copy of filename in bfd struct.

The patch below fixes this problem on gdb side. Ok?

Thanks,
--
Edjunior

gdb/
2014-01-03  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* gdb_bfd.c (gdb_bfd_stash_filename): Fix copy of filename in bfd's
	filename field using xstrdup.

---
 gdb/gdb_bfd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 36c4630..1b290c2 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -69,7 +69,7 @@ gdb_bfd_stash_filename (struct bfd *abfd)
   strcpy (data, name);
 
   /* Unwarranted chumminess with BFD.  */
-  abfd->filename = data;
+  abfd->filename = xstrdup (data);
 }
 
 /* An object of this type is stored in each BFD's user data.  */
-- 
1.7.9.5


             reply	other threads:[~2014-01-03 12:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03 12:59 Edjunior Barbosa Machado [this message]
2014-01-03 14:38 ` nick clifton
2014-01-03 17:53   ` Doug Evans

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=1388753936-2835-1-git-send-email-emachado@linux.vnet.ibm.com \
    --to=emachado@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nickc@redhat.com \
    /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