Bug 14494

Summary: gdb crashes in bfd_getl16 on debuginfo file
Product: gdb Reporter: Arjan van de Ven <arjan>
Component: gdbAssignee: Jan Kratochvil <jan>
Status: RESOLVED FIXED    
Severity: normal CC: jan
Priority: P2    
Version: 7.5   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: the libc.so file that causes the crash

Description Arjan van de Ven 2012-08-18 13:42:19 UTC
Created attachment 6590 [details]
the libc.so file that causes the crash

gdb -readnow /usr/lib/debug/lib64/libc-2.16.so.debug

gives the following backtrace:


#0  bfd_getl16 (p=0x7fd47abc965b) at libbfd.c:570
#1  0x000000000057333a in read_2_bytes (buf=0x7fd47abc965b <Address 0x7fd47abc965b out of bounds>, abfd=<optimized out>)
    at dwarf2read.c:13088
#2  dwarf_parse_macro_header (opcode_definitions=opcode_definitions@entry=0x7fff1d59ddf0, abfd=abfd@entry=0x26ed6c0,
    mac_ptr=0x7fd47abc965b <Address 0x7fd47abc965b out of bounds>, offset_size=offset_size@entry=0x7fff1d59dde8,
    section_is_gnu=section_is_gnu@entry=1) at dwarf2read.c:17156
#3  0x000000000057c1ac in dwarf_decode_macros (cu=cu@entry=0x27929b0, offset=5835,
    comp_dir=0x7fd47c59d368 <Address 0x7fd47c59d368 out of bounds>, section_is_gnu=section_is_gnu@entry=1)
    at dwarf2read.c:17509
#4  0x0000000000589a81 in read_file_scope (cu=<optimized out>, die=<optimized out>) at dwarf2read.c:7691
#5  process_die (die=<optimized out>, cu=cu@entry=0x27929b0) at dwarf2read.c:6872
#6  0x000000000058d7da in process_full_comp_unit (pretend_language=language_minimal, per_cu=0x2702790) at dwarf2read.c:6680
#7  process_queue () at dwarf2read.c:6250
#8  dw2_do_instantiate_symtab (per_cu=per_cu@entry=0x2702790) at dwarf2read.c:2177
#9  0x000000000058dd2c in dw2_instantiate_symtab (per_cu=0x2702790) at dwarf2read.c:2198
#10 0x000000000058e192 in dw2_expand_all_symtabs (objfile=<optimized out>) at dwarf2read.c:3136
#11 0x0000000000509996 in symbol_file_add_with_addrs_or_offsets (abfd=<optimized out>, add_flags=6, addrs=addrs@entry=0x0,
    flags=<optimized out>, flags@entry=0, parent=parent@entry=0x0, num_offsets=0, offsets=0x0) at symfile.c:1126
#12 0x0000000000509c4a in symbol_file_add_from_bfd (abfd=<optimized out>, add_flags=<optimized out>, addrs=addrs@entry=0x0,
    flags=flags@entry=0, parent=parent@entry=0x0) at symfile.c:1198
#13 0x0000000000509c91 in symbol_file_add (name=name@entry=0x7fff1d59fdaa "/usr/lib/debug/lib64/libc-2.16.so.debug",
    add_flags=<optimized out>, addrs=addrs@entry=0x0, flags=flags@entry=0) at symfile.c:1210
#14 0x000000000050a045 in symbol_file_add_main_1 (args=0x7fff1d59fdaa "/usr/lib/debug/lib64/libc-2.16.so.debug", from_tty=1,
    flags=0) at symfile.c:1235
#15 0x000000000052e6cf in catch_command_errors (command=0x50a1a0 <symbol_file_add_main>,
    arg=arg@entry=0x7fff1d59fdaa "/usr/lib/debug/lib64/libc-2.16.so.debug", from_tty=1, mask=mask@entry=6) at exceptions.c:573
#16 0x0000000000530add in captured_main (data=data@entry=0x7fff1d59ea80) at main.c:899


(the crash happens also on a regular "bt" command of some crashed application, but this is the easiest testcase)
Comment 1 Arjan van de Ven 2012-08-18 13:44:09 UTC
(just to mention, I compressed the libc so file with XZ for size reasons)
Comment 2 Arjan van de Ven 2012-08-18 14:40:27 UTC
further investigation.. I can make the segfault go away if I use slightly different strip options on binaries. But that is likely only a workaround by avoiding the code that crashes
Comment 3 Jan Kratochvil 2012-08-18 16:59:31 UTC
[patch] Fix .debug_macro NOBITS crash (PR 14494)
http://sourceware.org/ml/gdb-patches/2012-08/msg00513.html
Comment 4 Sourceware Commits 2012-08-27 16:43:03 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	gdb_7_5-branch
Changes by:	jkratoch@sourceware.org	2012-08-27 16:42:55

Modified files:
	gdb            : ChangeLog dwarf2read.c 

Log message:
	gdb/
	PR gdb/14494.
	* dwarf2read.c (dwarf2_locate_sections): Move variable aflag here.
	Move the SEC_HAS_CONTENTS check here - for any NAMES use.
	(dwarf2_locate_sections) <eh_frame>: Move the variable and check from
	here.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.14469.2.27&r2=1.14469.2.28
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.687.2.1&r2=1.687.2.2
Comment 5 Sourceware Commits 2012-08-27 16:43:36 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2012-08-27 16:43:27

Modified files:
	gdb            : ChangeLog 

Log message:
	ChangeLog fix:
	PR gdb/14494.
	* dwarf2read.c (dwarf2_locate_sections): Move variable aflag here.
	Move the SEC_HAS_CONTENTS check here - for any NAMES use.
	(dwarf2_locate_sections) <eh_frame>: Move the variable and check from
	here.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14632&r2=1.14633
Comment 6 Jan Kratochvil 2012-08-27 16:45:36 UTC
Checked in and also for 7.5.1.