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.
Created attachment 6641 [details] testcase
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
Patch checked in.