Bug 11465 - Crash on NULL TYPE_FIELD_TYPE
Summary: Crash on NULL TYPE_FIELD_TYPE
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.1
Assignee: Keith Seitz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-01 19:56 UTC by Jan Kratochvil
Modified: 2010-12-13 23:51 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments
The first reproducer as a GDB testcase. (2.02 KB, patch)
2010-04-01 19:57 UTC, Jan Kratochvil
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-04-01 19:56:52 UTC
This bugreport assumes this patch is reverted.
Going to revert this patch now.
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.376&r2=1.377
With the patch it does not crash but it has incorrect behavior(*).


This reproducer would crash:
cat <<HERE | g++ -c -o x.o -g -x c++ -; gdb -nx -readnow ./x.o
namespace N {
  class C {
  public:
    typedef void (*t) (C);
    void m (t);
  };
  typedef C::t u;
};
N::u f;
HERE

Attaching it in .s form to overcome possible g++ differences.

It is due to dwarf2_physname() accessing unfinished types being read-in,
dwarf2_physname() is not in FSF gdb-7.1 but it is now in FSF GDB HEAD.
=> It is a regression of current FSF GDB HEAD agains FSF GDB 7.1.


(*) The incorrect behavior with that first patch included can be shown on:
------------------------------------------------------------------------------
namespace N {
  class C {
  public:
    typedef void (*t) (C);
    C (t) {}
  };
  typedef C::t u;
  u f;
  C c (f);
  class CC {
  public:
    CC (int) {}
  } cc (1);
};
int
main ()
{
  return 0;
}
------------------------------------------------------------------------------
gcc-4.4.3-4.fc12.x86_64 and g++ (GCC) 4.4.4 20100401 (prerelease)
(gdb) p N::c.C
Cannot take address of method C.
(gdb) p N::cc.CC
$1 = {void (N::CC *, int)} 0x4005c4 <N::CC::CC(int)>
It is because internally GDB at line
  fnp->physname = physname ? physname : "";
detects
"N::C::C(void (*)())"
"N::CC::CC(int)"
where "()" should be "(C)".
------------------------------------------------------------------------------
g++ (GCC) 4.5.0 20100401 (experimental)
(gdb) p N::c.C
$1 = {void (N::C *, N::C::t)} 0x400516 <N::C::C(N::C::t)>
(gdb) p N::cc.CC
$2 = {void (N::CC *, int)} 0x400524 <N::CC::CC(int)>
looks correct but still it does not work:
(gdb) ptype N::C::t
type = void (*)(void)
Comment 1 Jan Kratochvil 2010-04-01 19:57:53 UTC
Created attachment 4699 [details]
The first reproducer as a GDB testcase.
Comment 2 Jan Kratochvil 2010-04-02 09:36:49 UTC
The reason for GDB not crashing on GCC-4.5 output is due to GCC-4.5 producing
incomplete debug information, filed as gcc PR debug/43628:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43628
Comment 3 Sourceware Commits 2010-08-20 17:16:34 UTC
Subject: Bug 11465

CVSROOT:	/cvs/src
Module name:	src
Changes by:	kseitz@sourceware.org	2010-08-20 17:16:15

Modified files:
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.dwarf2: pr11465.exp pr11465.S 
	                          dw2-double-set-die-type.S 
	                          dw2-double-set-die-type.exp 

Log message:
	PR symtab/11465:
	* gdb.dwarf2/pr11465.exp: New test.
	* gdb.dwarf2/pr11465.S: New file.
	* gdb.dwarf2/dw2-double-set-die-type.S: New file.
	* gdb.dwarf2/dw2-double-set-die-type.exp: New test.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2423&r2=1.2424
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/pr11465.exp.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/pr11465.S.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.exp.diff?cvsroot=src&r1=NONE&r2=1.1

Comment 4 Sourceware Commits 2010-08-20 17:17:01 UTC
Subject: Bug 11465

CVSROOT:	/cvs/src
Module name:	src
Changes by:	kseitz@sourceware.org	2010-08-20 17:16:45

Modified files:
	gdb            : ChangeLog dwarf2read.c 

Log message:
	PR symtab/11465:
	* dwarf2read.c (struct delayed_method_info): New struct.
	(struct dwarf2_cu): Add vector method_list.
	(scan_partial_symbols): Count methods for union, class, structure,
	and interface types.
	(add_to_method_list): New function.
	(free_delayed_list): New function.
	(compute_delayed_physnames): New function.
	(process_full_comp_unit): Make a cleanup for the CU's delayed
	physname list, compute the delayed physnames, and free the
	the list.
	(dwarf2_add_member_fn): For C++ and Java, delay the computation
	of the physname until after the CU is read.
	
	* dwarf2read.c (read_structure_type): Check if the current
	DIE's type was already completed after dwarf2_full_name
	was called.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12102&r2=1.12103
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.438&r2=1.439

Comment 5 Keith Seitz 2010-12-13 23:51:08 UTC
I checked in a patch for this a while ago. Time to close the bug report.