* [RFA] Avoid segfault in decode_line_2
@ 2003-07-11 7:06 Michal Ludvig
2003-07-18 13:18 ` Elena Zannoni
0 siblings, 1 reply; 4+ messages in thread
From: Michal Ludvig @ 2003-07-11 7:06 UTC (permalink / raw)
To: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 717 bytes --]
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<int>::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
[-- Attachment #2: linespec-safety-1.diff --]
[-- Type: text/plain, Size: 1123 bytes --]
2003-07-11 Michal Ludvig <mludvig@suse.cz>
* 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");
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFA] Avoid segfault in decode_line_2 2003-07-11 7:06 [RFA] Avoid segfault in decode_line_2 Michal Ludvig @ 2003-07-18 13:18 ` Elena Zannoni 2003-07-23 19:38 ` Elena Zannoni 0 siblings, 1 reply; 4+ messages in thread From: Elena Zannoni @ 2003-07-18 13:18 UTC (permalink / raw) To: Michal Ludvig; +Cc: GDB Patches 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<int>::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 <mludvig@suse.cz> > > * 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Avoid segfault in decode_line_2 2003-07-18 13:18 ` Elena Zannoni @ 2003-07-23 19:38 ` Elena Zannoni 2003-07-24 6:27 ` Michal Ludvig 0 siblings, 1 reply; 4+ messages in thread From: Elena Zannoni @ 2003-07-23 19:38 UTC (permalink / raw) To: Michal Ludvig; +Cc: GDB Patches 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<int>::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 <mludvig@suse.cz> > > > > * 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 <mludvig@suse.cz> Elena Zannoni <ezannoni@redhat.com> * 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"); ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Avoid segfault in decode_line_2 2003-07-23 19:38 ` Elena Zannoni @ 2003-07-24 6:27 ` Michal Ludvig 0 siblings, 0 replies; 4+ messages in thread From: Michal Ludvig @ 2003-07-24 6:27 UTC (permalink / raw) To: Elena Zannoni; +Cc: GDB Patches Elena Zannoni told me that: > Elena Zannoni writes: > > Michal Ludvig writes: > > > Hi all, > > > this patch fixes a problem that I met while debugging a testsuite > > > failure on amd64: > > > > 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 <mludvig@suse.cz> > Elena Zannoni <ezannoni@redhat.com> > > * linespec.c (decode_line_2): Avoid crash if > find_function_start_sal() returns empty record. Thanks! (And sorry, I forgot to do it... :-) Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * (+420) 296.545.373 * http://www.suse.cz ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-24 6:27 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-07-11 7:06 [RFA] Avoid segfault in decode_line_2 Michal Ludvig 2003-07-18 13:18 ` Elena Zannoni 2003-07-23 19:38 ` Elena Zannoni 2003-07-24 6:27 ` Michal Ludvig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox