From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28264 invoked by alias); 10 Aug 2007 00:13:01 -0000 Received: (qmail 28239 invoked by uid 22791); 10 Aug 2007 00:13:00 -0000 X-Spam-Check-By: sourceware.org Received: from a.mail.sonic.net (HELO a.mail.sonic.net) (64.142.16.245) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 10 Aug 2007 00:12:58 +0000 Received: from webmail.sonic.net (b.webmail.sonic.net [64.142.100.148]) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id l7A0CjAe017831; Thu, 9 Aug 2007 17:12:45 -0700 Received: from 12.7.175.2 (SquirrelMail authenticated user msnyder) by webmail.sonic.net with HTTP; Thu, 9 Aug 2007 17:12:45 -0700 (PDT) Message-ID: <21641.12.7.175.2.1186704765.squirrel@webmail.sonic.net> In-Reply-To: <1186699391.4524.12.camel@localhost> References: <23585.12.7.175.2.1186282957.squirrel@webmail.sonic.net> <21109.12.7.175.2.1186596556.squirrel@webmail.sonic.net> <1186699391.4524.12.camel@localhost> Date: Fri, 10 Aug 2007 00:13:00 -0000 Subject: Re: [PATCH] solib-svr4.c, several memory leaks From: msnyder@sonic.net To: luisgpm@linux.vnet.ibm.com, gdb-patches@sourceware.org Cc: jimb@codesourcery.com, kevinb@redhat.com User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070809171245_94405" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00196.txt.bz2 ------=_20070809171245_94405 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 1258 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. ------=_20070809171245_94405 Content-Type: text/plain; name="enable_break.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="enable_break.txt" Content-length: 1050 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.")); ------=_20070809171245_94405--