public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix copy of filename in bfd's filename field
@ 2014-01-03 12:59 Edjunior Barbosa Machado
  2014-01-03 14:38 ` nick clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Edjunior Barbosa Machado @ 2014-01-03 12:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: nickc

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix copy of filename in bfd's filename field
  2014-01-03 12:59 [PATCH] Fix copy of filename in bfd's filename field Edjunior Barbosa Machado
@ 2014-01-03 14:38 ` nick clifton
  2014-01-03 17:53   ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: nick clifton @ 2014-01-03 14:38 UTC (permalink / raw)
  To: Edjunior Barbosa Machado, gdb-patches

Hi 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.


> @@ -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.  */

It might be nice to remove the comment too. :-)

Cheers
   Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix copy of filename in bfd's filename field
  2014-01-03 14:38 ` nick clifton
@ 2014-01-03 17:53   ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2014-01-03 17:53 UTC (permalink / raw)
  To: nick clifton; +Cc: Edjunior Barbosa Machado, gdb-patches

Hi Nick,

On Fri, Jan 3, 2014 at 6:35 AM, nick clifton <nickc@redhat.com> wrote:
> Hi 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.
>
>
>
>> @@ -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.  */
>
>
> It might be nice to remove the comment too. :-)
>
> Cheers
>   Nick

Seems like bfd should export an API routine that sets abfd->filename,
so that the implementation detail that it lives in malloc space is
kept within bfd.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-03 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-03 12:59 [PATCH] Fix copy of filename in bfd's filename field Edjunior Barbosa Machado
2014-01-03 14:38 ` nick clifton
2014-01-03 17:53   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).