Bug 14601 - segv when reading DW_TAG_imported_declaration,module
Summary: segv when reading DW_TAG_imported_declaration,module
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-20 20:49 UTC by dje
Modified: 2012-10-03 17:07 UTC (History)
0 users

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


Attachments
testcase (534 bytes, text/x-c++src)
2012-09-20 20:52 UTC, dje
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dje 2012-09-20 20:49:20 UTC
buildsym.c:using_directive is assumed to be NULL at the start of symbol processing.  Not all code paths ensure this.  If a DW_TAG_imported_declaration,module happens outside of finish_block_internal or push_context, it won't get reset back to NULL, leaving a potentially dangling value.

To see the crash you need to compile the testcase with -fdebug-types-section, but there's nothing inherently dwarf4 or even dwarf-specific here.

bash$ gdb -nx testsuite/gdb.cp/using-crash
(gdb) b foo
(gdb) run
(gdb) kill
(gdb) file testsuite/gdb.cp/using-crash
Load new symbol table from "/foo/testsuite/gdb.cp/using-crash"? (y or n) y
Reading symbols from /foo/testsuite/gdb.cp/using-crash...done.
Segmentation fault

Patch to follow.
Comment 1 dje 2012-09-20 20:52:29 UTC
Created attachment 6641 [details]
testcase
Comment 2 Sourceware Commits 2012-10-03 17:05:05 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	devans@sourceware.org	2012-10-03 17:05:00

Modified files:
	gdb            : ChangeLog buildsym.c 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.cp: using-crash.cc using-crash.exp 

Log message:
	PR symtab/14601
	* buildsym.c (buildsym_init): Reset using_directives to NULL.
	
	testsuite/
	* gdb.cp/using-crash.exp: New file.
	* gdb.cp/using-crash.cc: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14726&r2=1.14727
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/buildsym.c.diff?cvsroot=src&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3401&r2=1.3402
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/using-crash.cc.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/using-crash.exp.diff?cvsroot=src&r1=NONE&r2=1.1
Comment 3 dje 2012-10-03 17:07:04 UTC
Patch checked in.