* [PATCH] solib-svr4.c, several memory leaks
@ 2007-08-05 3:02 msnyder
2007-08-06 22:14 ` Jim Blandy
0 siblings, 1 reply; 8+ messages in thread
From: msnyder @ 2007-08-05 3:02 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 143-144-145.txt --]
[-- Type: text/plain, Size: 2077 bytes --]
2007-08-04 Michael Snyder <msnyder@access-company.com>
* solib-svr4.c (open_symbol_file_object): Memory leak.
(svr4_current_sos): Ditto.
(enable_break): Ditto.
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.71
diff -p -r1.71 solib-svr4.c
*** solib-svr4.c 25 Jul 2007 02:12:33 -0000 1.71
--- solib-svr4.c 5 Aug 2007 02:59:55 -0000
*************** open_symbol_file_object (void *from_ttyp
*** 623,628 ****
--- 623,629 ----
/* Now fetch the filename from target memory. */
target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
+ make_cleanup (xfree, filename);
if (errcode)
{
*************** open_symbol_file_object (void *from_ttyp
*** 631,637 ****
return 0;
}
- make_cleanup (xfree, filename);
/* Have a pathname: read the symbol file. */
symbol_file_add_main (filename, from_tty);
--- 632,637 ----
*************** svr4_current_sos (void)
*** 751,759 ****
{
strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
- xfree (buffer);
strcpy (new->so_original_name, new->so_name);
}
/* If this entry has no name, or its name matches the name
for the main executable, don't include it in the list. */
--- 751,759 ----
{
strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
strcpy (new->so_original_name, new->so_name);
}
+ xfree (buffer);
/* If this entry has no name, or its name matches the name
for the main executable, don't include it in the list. */
*************** enable_break (void)
*** 1008,1013 ****
--- 1008,1014 ----
tmp_fd = solib_open (buf, &tmp_pathname);
if (tmp_fd >= 0)
tmp_bfd = bfd_fopen (tmp_pathname, gnutarget, FOPEN_RB, tmp_fd);
+ xfree (tmp_pathname);
if (tmp_bfd == NULL)
goto bkpt_at_symbol;
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] solib-svr4.c, several memory leaks
2007-08-05 3:02 [PATCH] solib-svr4.c, several memory leaks msnyder
@ 2007-08-06 22:14 ` Jim Blandy
2007-08-06 22:43 ` Kevin Buettner
2007-08-08 18:09 ` msnyder
0 siblings, 2 replies; 8+ messages in thread
From: Jim Blandy @ 2007-08-06 22:14 UTC (permalink / raw)
To: msnyder; +Cc: gdb-patches
msnyder@sonic.net writes:
> 2007-08-04 Michael Snyder <msnyder@access-company.com>
>
> * solib-svr4.c (open_symbol_file_object): Memory leak.
> (svr4_current_sos): Ditto.
> (enable_break): Ditto.
Looks okay to me.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] solib-svr4.c, several memory leaks
2007-08-06 22:14 ` Jim Blandy
@ 2007-08-06 22:43 ` Kevin Buettner
2007-08-08 18:09 ` msnyder
1 sibling, 0 replies; 8+ messages in thread
From: Kevin Buettner @ 2007-08-06 22:43 UTC (permalink / raw)
To: gdb-patches
On Mon, 06 Aug 2007 15:13:52 -0700
Jim Blandy <jimb@codesourcery.com> wrote:
> msnyder@sonic.net writes:
> > 2007-08-04 Michael Snyder <msnyder@access-company.com>
> >
> > * solib-svr4.c (open_symbol_file_object): Memory leak.
> > (svr4_current_sos): Ditto.
> > (enable_break): Ditto.
>
> Looks okay to me.
Agreed.
Kevin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] solib-svr4.c, several memory leaks
2007-08-06 22:14 ` Jim Blandy
2007-08-06 22:43 ` Kevin Buettner
@ 2007-08-08 18:09 ` msnyder
2007-08-09 22:45 ` Luis Machado
[not found] ` <1186699391.4524.12.camel@localhost>
1 sibling, 2 replies; 8+ messages in thread
From: msnyder @ 2007-08-08 18:09 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
>
> msnyder@sonic.net writes:
>> 2007-08-04 Michael Snyder <msnyder@access-company.com>
>>
>> * solib-svr4.c (open_symbol_file_object): Memory leak.
>> (svr4_current_sos): Ditto.
>> (enable_break): Ditto.
>
> Looks okay to me.
Committed. Thanks Jim and Kevin.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] solib-svr4.c, several memory leaks
2007-08-08 18:09 ` msnyder
@ 2007-08-09 22:45 ` Luis Machado
[not found] ` <1186699391.4524.12.camel@localhost>
1 sibling, 0 replies; 8+ messages in thread
From: Luis Machado @ 2007-08-09 22:45 UTC (permalink / raw)
To: Jim Blandy, gdb-patches
Folks,
GDB started acting strange today, segfaulting when trying to open some
binaries, GDB itself included. Other binaries would work OK.
Log:
-------
~/builds/gdb-head/> gdb-head-64bit/gdb/gdb gdb-head-64bit/gdb/gdb
GNU gdb 6.6.50.20070809-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "powerpc64-unknown-linux-gnu"...
startUsing host libthread_db library "/lib64/ppc970/libthread_db.so.1".
(gdb) start
Breakpoint 1 at 0x10060b3c: file gdb-head/gdb/gdb.c, line 30.
Starting program: gdb-head-64bit/gdb/gdb
BFD: reopening : No such file or directory
Segmentation fault
-------
I tracked down the root of the problem and this patch appears to be the
problem. Reverting it back fixes the problem.
Backtrace output:
-------
Program received signal SIGSEGV, Segmentation fault.
0x00000400002a8b30 in .strcmp () from /lib64/tls/libc.so.6
(gdb) bt
#0 0x00000400002a8b30 in .strcmp () from /lib64/tls/libc.so.6
#1 0x0000000010089d14 in bfd_lookup_symbol (abfd=0x1095a980,
symname=0x106de700 "r_debug_state")
at gdb-head/gdb/solib-svr4.c:305
-------
Best regards,
Luis
On Wed, 2007-08-08 at 11:09 -0700, msnyder@sonic.net wrote:
> >
> > msnyder@sonic.net writes:
> >> 2007-08-04 Michael Snyder <msnyder@access-company.com>
> >>
> >> * solib-svr4.c (open_symbol_file_object): Memory leak.
> >> (svr4_current_sos): Ditto.
> >> (enable_break): Ditto.
> >
> > Looks okay to me.
>
> Committed. Thanks Jim and Kevin.
>
>
--
Luis Machado
Software Engineer
IBM Linux Technology Center
LoP Toolchain/Debuggers' team
Phone: +55 19-2132-2218
T/L: 839-2218
e-mail: luisgpm@vnet.linux.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread[parent not found: <1186699391.4524.12.camel@localhost>]
* Re: [PATCH] solib-svr4.c, several memory leaks
[not found] ` <1186699391.4524.12.camel@localhost>
@ 2007-08-09 23:39 ` msnyder
2007-08-10 0:13 ` msnyder
1 sibling, 0 replies; 8+ messages in thread
From: msnyder @ 2007-08-09 23:39 UTC (permalink / raw)
To: luisgpm; +Cc: gdb-patches
Thanks -- looking into it.
> Folks,
>
> GDB started acting strange today, segfaulting when trying to open some
> binaries, GDB itself included. Other binaries would work OK.
>
> Log:
>
> -------
> ~/builds/gdb-head/> gdb-head-64bit/gdb/gdb gdb-head-64bit/gdb/gdb
> GNU gdb 6.6.50.20070809-cvs
> Copyright (C) 2007 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for
> details.
> This GDB was configured as "powerpc64-unknown-linux-gnu"...
> startUsing host libthread_db library "/lib64/ppc970/libthread_db.so.1".
> (gdb) start
> Breakpoint 1 at 0x10060b3c: file gdb-head/gdb/gdb.c, line 30.
> Starting program: gdb-head-64bit/gdb/gdb
> BFD: reopening : No such file or directory
>
> Segmentation fault
> -------
>
>
> I tracked down the root of the problem and this patch appears to be the
> problem. Reverting it back fixes the problem.
>
> Backtrace output:
> -------
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000400002a8b30 in .strcmp () from /lib64/tls/libc.so.6
> (gdb) bt
> #0 0x00000400002a8b30 in .strcmp () from /lib64/tls/libc.so.6
> #1 0x0000000010089d14 in bfd_lookup_symbol (abfd=0x1095a980,
> symname=0x106de700 "r_debug_state")
> at gdb-head/gdb/solib-svr4.c:305
> -------
>
> Best regards,
> Luis
>
> On Wed, 2007-08-08 at 11:09 -0700, msnyder@sonic.net wrote:
>> >
>> > msnyder@sonic.net writes:
>> >> 2007-08-04 Michael Snyder <msnyder@access-company.com>
>> >>
>> >> * solib-svr4.c (open_symbol_file_object): Memory leak.
>> >> (svr4_current_sos): Ditto.
>> >> (enable_break): Ditto.
>> >
>> > Looks okay to me.
>>
>> Committed. Thanks Jim and Kevin.
>>
>>
> --
> Luis Machado
> Software Engineer
> IBM Linux Technology Center
> LoP Toolchain/Debuggers' team
> Phone: +55 19-2132-2218
> T/L: 839-2218
> e-mail: luisgpm@vnet.linux.ibm.com
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] solib-svr4.c, several memory leaks
[not found] ` <1186699391.4524.12.camel@localhost>
2007-08-09 23:39 ` msnyder
@ 2007-08-10 0:13 ` msnyder
2007-08-10 7:16 ` Markus Deuling
1 sibling, 1 reply; 8+ messages in thread
From: msnyder @ 2007-08-10 0:13 UTC (permalink / raw)
To: luisgpm, gdb-patches; +Cc: jimb, kevinb
[-- Attachment #1: Type: text/plain, Size: 1258 bytes --]
Jim, Kevin,
Apparently we can't free the tmp name while bfd has the file open.
Moving the xfree to later, after it has been closed, seems to fix
the segfault.
See attached patch.
Michael
> Folks,
>
> GDB started acting strange today, segfaulting when trying to open some
> binaries, GDB itself included. Other binaries would work OK.
>
> Log:
>
> -------
> ~/builds/gdb-head/> gdb-head-64bit/gdb/gdb gdb-head-64bit/gdb/gdb
> GNU gdb 6.6.50.20070809-cvs
> Copyright (C) 2007 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for
> details.
> This GDB was configured as "powerpc64-unknown-linux-gnu"...
> startUsing host libthread_db library "/lib64/ppc970/libthread_db.so.1".
> (gdb) start
> Breakpoint 1 at 0x10060b3c: file gdb-head/gdb/gdb.c, line 30.
> Starting program: gdb-head-64bit/gdb/gdb
> BFD: reopening : No such file or directory
>
> Segmentation fault
> -------
>
>
> I tracked down the root of the problem and this patch appears to be the
> problem. Reverting it back fixes the problem.
[-- Attachment #2: enable_break.txt --]
[-- Type: text/plain, Size: 1050 bytes --]
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.72
diff -p -r1.72 solib-svr4.c
*** solib-svr4.c 8 Aug 2007 18:08:52 -0000 1.72
--- solib-svr4.c 10 Aug 2007 00:09:19 -0000
*************** enable_break (void)
*** 1008,1014 ****
tmp_fd = solib_open (buf, &tmp_pathname);
if (tmp_fd >= 0)
tmp_bfd = bfd_fopen (tmp_pathname, gnutarget, FOPEN_RB, tmp_fd);
- xfree (tmp_pathname);
if (tmp_bfd == NULL)
goto bkpt_at_symbol;
--- 1008,1013 ----
*************** enable_break (void)
*** 1102,1107 ****
--- 1101,1107 ----
/* For whatever reason we couldn't set a breakpoint in the dynamic
linker. Warn and drop into the old code. */
bkpt_at_symbol:
+ xfree (tmp_pathname);
warning (_("Unable to find dynamic linker breakpoint function.\n"
"GDB will be unable to debug shared library initializers\n"
"and track explicitly loaded dynamic code."));
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] solib-svr4.c, several memory leaks
2007-08-10 0:13 ` msnyder
@ 2007-08-10 7:16 ` Markus Deuling
0 siblings, 0 replies; 8+ messages in thread
From: Markus Deuling @ 2007-08-10 7:16 UTC (permalink / raw)
To: msnyder; +Cc: luisgpm, gdb-patches, jimb, kevinb
msnyder@sonic.net schrieb:
> Jim, Kevin,
>
> Apparently we can't free the tmp name while bfd has the file open.
> Moving the xfree to later, after it has been closed, seems to fix
> the segfault.
>
> See attached patch.
> Michael
>
>> Folks,
>>
>> GDB started acting strange today, segfaulting when trying to open some
>> binaries, GDB itself included. Other binaries would work OK.
>>
>> Log:
>>
>> -------
>> ~/builds/gdb-head/> gdb-head-64bit/gdb/gdb gdb-head-64bit/gdb/gdb
>> GNU gdb 6.6.50.20070809-cvs
>> Copyright (C) 2007 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and you
>> are
>> welcome to change it and/or distribute copies of it under certain
>> conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB. Type "show warranty" for
>> details.
>> This GDB was configured as "powerpc64-unknown-linux-gnu"...
>> startUsing host libthread_db library "/lib64/ppc970/libthread_db.so.1".
>> (gdb) start
>> Breakpoint 1 at 0x10060b3c: file gdb-head/gdb/gdb.c, line 30.
>> Starting program: gdb-head-64bit/gdb/gdb
>> BFD: reopening : No such file or directory
>>
>> Segmentation fault
>> -------
>>
>>
>> I tracked down the root of the problem and this patch appears to be the
>> problem. Reverting it back fixes the problem.
>
Yes, it does. Please commit. These are my current testsuite results on x86 :-( :
# of expected passes 5706
# of unexpected failures 1233
<...>
# of unresolved testcases 4334
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-08-10 7:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-05 3:02 [PATCH] solib-svr4.c, several memory leaks msnyder
2007-08-06 22:14 ` Jim Blandy
2007-08-06 22:43 ` Kevin Buettner
2007-08-08 18:09 ` msnyder
2007-08-09 22:45 ` Luis Machado
[not found] ` <1186699391.4524.12.camel@localhost>
2007-08-09 23:39 ` msnyder
2007-08-10 0:13 ` msnyder
2007-08-10 7:16 ` Markus Deuling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox