From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15252 invoked by alias); 23 Jul 2003 19:38:06 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15241 invoked from network); 23 Jul 2003 19:38:06 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 23 Jul 2003 19:38:06 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h6NJc5H00842 for ; Wed, 23 Jul 2003 15:38:05 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h6NJc5I32730 for ; Wed, 23 Jul 2003 15:38:05 -0400 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h6NJc4v04106 for ; Wed, 23 Jul 2003 15:38:04 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id A5D692CB2D; Wed, 23 Jul 2003 15:45:18 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16158.58830.541858.789928@localhost.redhat.com> Date: Wed, 23 Jul 2003 19:38:00 -0000 To: Michal Ludvig Cc: GDB Patches Subject: Re: [RFA] Avoid segfault in decode_line_2 In-Reply-To: <16151.62826.629842.506716@localhost.redhat.com> References: <3F0E61E7.5020900@suse.cz> <16151.62826.629842.506716@localhost.redhat.com> X-SW-Source: 2003-07/txt/msg00411.txt.bz2 Elena Zannoni writes: > Michal Ludvig writes: > > Hi all, > > this patch fixes a problem that I met while debugging a testsuite > > failure on amd64: > > > > > Running gdb-head/gdb/testsuite/gdb.c++/templates.exp ... > > > FAIL: gdb.c++/templates.exp: constructor breakpoint (timeout) > > > > (gdb) break T5::T5 > > -> Segfault in linespec.c:486 [decode_line_2()] because > > values.sals[i].symtab is NULL and dereferencing of > > values.sals[i].symtab->filename crashes. > > > > After some investigation I found out that .debug_line section of the > > input file was broken (reported to binutils@ list). > > However broken debug info is not an excuse for GDB to crash. > > > > OK to apply to head and branch? > > > > Michal Ludvig > > -- > > * SuSE CR, s.r.o * mludvig@suse.cz > > * (+420) 296.545.373 * http://www.suse.cz > > 2003-07-11 Michal Ludvig > > > > * linespec.c (decode_line_2): Avoid crash if > > find_function_start_sal() returns empty record. > > > > Index: linespec.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/linespec.c,v > > retrieving revision 1.49 > > diff -u -p -r1.49 linespec.c > > --- linespec.c 8 Jun 2003 18:27:13 -0000 1.49 > > +++ linespec.c 11 Jul 2003 06:59:01 -0000 > > @@ -483,11 +483,16 @@ decode_line_2 (struct symbol *sym_arr[], > > if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) > > { > > values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); > > - printf_unfiltered ("[%d] %s at %s:%d\n", > > + printf_unfiltered ("[%d] %s at %s:%d ", > > (i + 2), > > SYMBOL_PRINT_NAME (sym_arr[i]), > > - values.sals[i].symtab->filename, > > + values.sals[i].symtab ? > > + values.sals[i].symtab->filename : > > + "?FILE", > > values.sals[i].line); > > + if (! values.sals[i].symtab) > > + printf_unfiltered ("[No symtab? Probably a broken debug info...]" ); > > + printf_unfiltered ("\n"); > > } > > else > > printf_unfiltered ("?HERE\n"); > > Yes, but, could you change this to use an if (values.sals[i].symtab) > before the printf_filtered and avoid the conditional expression? You > will end up getting rid of the if() for the No symtab?.. case as well, > since that can be folded into a single printf. > > elena I checked in the following: 2003-07-23 Michal Ludvig Elena Zannoni * linespec.c (decode_line_2): Avoid crash if find_function_start_sal() returns empty record. Index: linespec.c =================================================================== RCS file: /cvs/uberbaum/gdb/linespec.c,v retrieving revision 1.49 diff -u -p -r1.49 linespec.c --- linespec.c 8 Jun 2003 18:27:13 -0000 1.49 +++ linespec.c 23 Jul 2003 19:20:14 -0000 @@ -483,11 +483,18 @@ decode_line_2 (struct symbol *sym_arr[], if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) { values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); - printf_unfiltered ("[%d] %s at %s:%d\n", - (i + 2), - SYMBOL_PRINT_NAME (sym_arr[i]), - values.sals[i].symtab->filename, - values.sals[i].line); + if (values.sals[i].symtab) + printf_unfiltered ("[%d] %s at %s:%d\n", + (i + 2), + SYMBOL_PRINT_NAME (sym_arr[i]), + values.sals[i].symtab->filename, + values.sals[i].line); + else + printf_unfiltered ("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n", + (i + 2), + SYMBOL_PRINT_NAME (sym_arr[i]), + values.sals[i].line); + } else printf_unfiltered ("?HERE\n");