Bug 750341

Summary: gdb crashes on some dwarf2 executables
Product: Red Hat Enterprise Linux 6 Reporter: Konstantin Volkov <wolf>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1CC: jan.kratochvil, mpolacek, pmuller
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-7.2-51.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 14:29:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch that fix the crash
none
Source code of crash-example
none
Binary of crash-example none

Description Konstantin Volkov 2011-10-31 18:56:39 UTC
Created attachment 531015 [details]
Patch that fix the crash

Description of problem:

gdb crashes on some dwarf2 executables with NULL symtab

Version-Release number of selected component (if applicable):

gdb-7.2-48.el6

How reproducible:
100%

Steps to Reproduce:
1. Build the dwarf2 with null symtab
2. Run gdb
3. Crash
  
Actual results:
Crash

Expected results:
Don't crash

Additional info:
With this small patch all is OK. Please, apply:

---

--- gdb-7.3/gdb/dwarf2read.c.orig	2011-10-27 16:11:01.000000000 +0400
+++ gdb-7.3/gdb/dwarf2read.c	2011-10-27 16:11:09.000000000 +0400
@@ -11444,7 +11444,8 @@ new_symbol_full (struct die_info *die, s
       /* For the benefit of old versions of GCC, check for anonymous
 	 namespaces based on the demangled name.  */
       if (!processing_has_namespace_info
-	  && cu->language == language_cplus)
+	  && cu->language == language_cplus
+	  && sym->symtab)
 	cp_scan_for_anonymous_namespaces (sym);
     }
   return (sym);

---

Comment 1 Jan Kratochvil 2011-10-31 19:06:23 UTC
Could you provide a reproducer for the crash?

"dwarf2 with null symtab" is too ambiguous to blindly try some.

Comment 3 Konstantin Volkov 2011-10-31 19:17:02 UTC
(In reply to comment #1)
> Could you provide a reproducer for the crash?

I'll attach it tomorrow. Thanx!

Comment 5 Konstantin Volkov 2011-11-03 13:39:28 UTC
Created attachment 531559 [details]
Source code of crash-example

Comment 6 Konstantin Volkov 2011-11-03 13:40:09 UTC
Created attachment 531560 [details]
Binary of crash-example

Comment 7 Jan Kratochvil 2011-11-03 14:27:54 UTC
It has been fixed upstream by:

ad387dddfa899b9ef76e3c2420b163e0ca47fe16 is the first bad (=good) commit
commit ad387dddfa899b9ef76e3c2420b163e0ca47fe16
Author: Aleksandar Ristovski <aristovski>
Date:   Thu Oct 20 20:06:11 2011 +0000

    	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
    	arguments by adding OBJFILE.  Instead of getting objfile from
    	symbol's symtab, use new argument OBJFILE.
    	* cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
    	arguments by adding OBJFILE.
    	* gdb/dwarf2read.c (new_symbol_full): Change call to
    	cp_scan_for_anonymous_namespaces to match new signature.
    	* gdb/stabsread.c (define_symbol): Change call to
    	cp_scan_for_anonymous_namespaces to match new signature.

To ensure it gets backported you should contact your RHEL support services.

Comment 12 Jan Kratochvil 2012-01-13 22:12:13 UTC
[patch] gdb crash in cp_scan_for_anonymous_namespace
http://sourceware.org/ml/gdb-patches/2011-10/msg00570.html

Comment 13 Jan Kratochvil 2012-01-14 10:50:08 UTC
[commit] testsuite: New gdb.dwarf2/dw2-namespaceless-anonymous.exp
http://sourceware.org/ml/gdb-patches/2012-01/msg00511.html

QA: New testcase:
gdb.dwarf2/dw2-namespaceless-anonymous.exp

Comment 17 errata-xmlrpc 2012-06-20 14:29:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0930.html