From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32168 invoked by alias); 16 Oct 2005 12:59:29 -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 32134 invoked by uid 22791); 16 Oct 2005 12:59:25 -0000 Received: from neonescio.viaisn.org (HELO neonescio.viaisn.org) (82.94.249.43) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 16 Oct 2005 12:59:25 +0000 Received: from 084-246-048-082.pn.nl ([84.246.48.82]) by neonescio.viaisn.org with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1ER86n-0008MJ-HA; Sun, 16 Oct 2005 14:59:25 +0200 Received: from localhost ([127.0.0.1] helo=localhost.localdomain.dekkers.cx) by localhost with esmtp (Exim 4.54) id 1ER86l-0002QL-I7; Sun, 16 Oct 2005 14:59:23 +0200 Date: Sun, 16 Oct 2005 12:59:00 -0000 Message-ID: <87psq5lis4.wl%jeroen@vrijschrift.org> From: Jeroen Dekkers To: gdb-gnats@sources.redhat.com, nobody@sources.redhat.com, alvaro@alobbs.com, gdb-prs@sources.redhat.com, gdb-patches@sources.redhat.com Subject: Re: gdb/2009: Segmentation faults on AMD64 User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 Emacs/22.0.50 (x86_64-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2005-10/txt/msg00132.txt.bz2 I debugged this segfault and it is caused by incorrect debug information generated by GCC on AMD64, see http://gcc.gnu.org/PR24400. The problem is that the filenumbers in the .debug_macinfo arex wrong. They jump from 0xf to 0x11, skipping 0x10, so the last filename has a number which isn't in the filename table. GDB blindly uses the number as index into the filename table, resulting in a segfault. The following patch adds a check whether the index isn't bigger than the size of the table. 2005-10-16 Jeroen Dekkers Fix PR gdb/2009. * dwarf2read.c (file_full_name): Check whether FILE isn't bigger than the size of the filename table. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.183 diff -u -p -r1.183 dwarf2read.c --- dwarf2read.c 1 Aug 2005 04:06:27 -0000 1.183 +++ dwarf2read.c 16 Oct 2005 12:43:23 -0000 @@ -8810,7 +8810,19 @@ dwarf_alloc_die (void) static char * file_full_name (int file, struct line_header *lh, const char *comp_dir) { - struct file_entry *fe = &lh->file_names[file - 1]; + struct file_entry *fe; + + /* Check whether FILE isn't bigger than the number of filenames in + the table. There used to be a bug in GCC (PR24400) which would + generate an index that is one higher than the size of the + table. */ + if (file > lh->num_file_names) + { + complaint (&symfile_complaints, _("invalid file index number in macro section")); + return xstrdup ("/invalid/file/index"); + } + + fe = &lh->file_names[file - 1]; if (IS_ABSOLUTE_PATH (fe->name)) return xstrdup (fe->name);