Bug 14983 - GDB 7.5.1 crash due to NULL pointer reference at -break-insert
Summary: GDB 7.5.1 crash due to NULL pointer reference at -break-insert
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: corefiles (show other bugs)
Version: 7.5
: P2 critical
Target Milestone: 7.7
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 15325 15343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-12-26 20:13 UTC by Gerard Zagema
Modified: 2013-04-25 16:27 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerard Zagema 2012-12-26 20:13:50 UTC
File: dwarf2read.c
Function:  process_full_comp_unit

Original:

  static_block = end_symtab_get_static_block (highpc + baseaddr, objfile, 0);

  /* If the comp unit has DW_AT_ranges, it may have discontiguous ranges.
     Also, DW_AT_ranges may record ranges not belonging to any child DIEs
     (such as virtual method tables).  Record the ranges in STATIC_BLOCK's
     addrmap to help ensure it has an accurate map of pc values belonging to
     this comp unit.  */

  dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu);
  symtab = end_symtab_from_static_block (static_block, objfile,
                                           SECT_OFF_TEXT (objfile), 0);

The pointer static_block can be NULL while iterating through the symbols. this will cause a crash of GDB.

I have this patched by:

  static_block = end_symtab_get_static_block (highpc + baseaddr, objfile, 0);

  /* If the comp unit has DW_AT_ranges, it may have discontiguous ranges.
     Also, DW_AT_ranges may record ranges not belonging to any child DIEs
     (such as virtual method tables).  Record the ranges in STATIC_BLOCK's
     addrmap to help ensure it has an accurate map of pc values belonging to
     this comp unit.  */

  // NOTE (Gerard#1#): Bug fix!!!!!!
  symtab = NULL; 
  if(static_block ) 
  {
        dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu);

        symtab = end_symtab_from_static_block (static_block, objfile,
                                                SECT_OFF_TEXT (objfile), 0);
  }
Comment 1 Tom Tromey 2013-03-06 22:02:49 UTC
It would be useful to know how to trigger the bug.
Comment 2 Gerard Zagema 2013-03-07 06:44:24 UTC
The bug can be triggered if you take an ARM build and load a file created with the RealView compiler from ELF.

I could send you such file but you also need another patch to solve another bug in the same file which takes care of the path separators, a bug which is for ages in GDB.

The previous versions always go right because the NULL_POINTER was tested and now it is used without test which will give a crash instantly if I try to set a breakpoint.

The 7.5.1 version is, with the modifications I did, working fine.

Regards

Gerard
Comment 3 Gerard Zagema 2013-03-07 06:46:18 UTC
The bug can be triggered if you take an ARM build and load a file created with the RealView compiler from ARM.

I could send you such file but you also need another patch to solve another bug in the same file which takes care of the path separators, a bug which is for ages in GDB.

The previous versions always go right because the NULL_POINTER was tested and now it is used without test which will give a crash instantly if I try to set a breakpoint.

The 7.5.1 version is, with the modifications I did, working fine.

Regards

Gerard
Comment 4 Tom Tromey 2013-03-08 16:03:29 UTC
(In reply to comment #3)
> The bug can be triggered if you take an ARM build and load a file created with
> the RealView compiler from ARM.
> 
> I could send you such file but you also need another patch to solve another bug
> in the same file which takes care of the path separators, a bug which is for
> ages in GDB.

If you could attach a small one, that would be helpful.
I am mostly concerned about how to write a regression test for this.
So I'd want to inspect the DWARF to see what is confusing gdb.

Could you please file the path separator thing, plus your patch,
as a separate bug?
Comment 5 Tom Tromey 2013-04-12 17:44:23 UTC
*** Bug 15325 has been marked as a duplicate of this bug. ***
Comment 6 Tom Tromey 2013-04-12 17:45:35 UTC
*** Bug 15343 has been marked as a duplicate of this bug. ***
Comment 7 Tom Tromey 2013-04-12 17:46:02 UTC
There is a patch pending:
http://sourceware.org/ml/gdb-patches/2013-04/msg00171.html
Comment 8 Sourceware Commits 2013-04-25 16:25:38 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2013-04-25 16:25:37

Modified files:
	gdb            : ChangeLog dwarf2read.c 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.dwarf2: nostaticblock.exp 

Log message:
	PR corefiles/14983:
	* dwarf2read.c (process_full_comp_unit): Always create a static
	block.
	gdb/testsuite
	* gdb.dwarf2/nostaticblock.exp: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15474&r2=1.15475
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.788&r2=1.789
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3638&r2=1.3639
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/nostaticblock.exp.diff?cvsroot=src&r1=NONE&r2=1.1
Comment 9 Tom Tromey 2013-04-25 16:27:26 UTC
Fix checked in.