This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/12538] New: gdb chokes on '\0' DW_FORM_strp DW_AT_name inDW_TAG_compile_unit


http://sourceware.org/bugzilla/show_bug.cgi?id=12538

           Summary: gdb chokes on '\0' DW_FORM_strp DW_AT_name in
                    DW_TAG_compile_unit
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: rguenth@gcc.gnu.org


I happen to have debug info that contains

 <0><bc224>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <bc225>   DW_AT_producer    : (indirect string, offset: 0x29): GNU C 4.5.1
2
0101208 [gcc-4_5-branch revision 167585]        
    <bc229>   DW_AT_language    : 1     (ANSI C)
    <bc22a>   DW_AT_name        : (indirect string, offset: 0x33dd7):   
    <bc22e>   DW_AT_comp_dir    : (indirect string, offset: 0xad57):
/usr/src/de
bug/qemu-kvm-0.14.0     
    <bc232>   DW_AT_low_pc      : 0x473990      
    <bc23a>   DW_AT_high_pc     : 0x4769b3      
    <bc242>   DW_AT_stmt_list   : 0x1f440       

(from kvm-qemu, source file yet to be identified via debug info contents ...,
debug-info producer is gcc 4.5.1)

Note that DW_AT_name is '\0'.

gdb crashes in this case because it reads this DW_AT_name attribute
setting DW_STRING to NULL via

    case DW_FORM_strp:
      DW_STRING (attr) = read_indirect_string (abfd, info_ptr, cu_header,
                                               &bytes_read);
      DW_STRING_IS_CANONICAL (attr) = 0;

and

static char *
read_indirect_string (bfd *abfd, gdb_byte *buf,
                      const struct comp_unit_head *cu_header,
                      unsigned int *bytes_read_ptr)
{
...
  if (dwarf2_per_objfile->str.buffer[str_offset] == '\0')
    return NULL;

so we end up passing NULL to start_psymtab_common

3265    /* Allocate a new partial symbol table structure.  */
3266    attr = dwarf2_attr (comp_unit_die, DW_AT_name, &cu);
3267    pst = start_psymtab_common (objfile, objfile->section_offsets,
3268                          (attr != NULL) ? DW_STRING (attr) : "",

which later results in a crash in

#0  0x00007ffff67f17e2 in __strlen_sse2 () from /lib64/libc.so.6


full backtrace:

#0  0x00007ffff67f17e2 in __strlen_sse2 () from /lib64/libc.so.6
#1  0x0000000000541967 in allocate_psymtab (filename=0x0, objfile=0xe4b530)
    at ../../gdb/psymtab.c:1605
#2  0x0000000000541a87 in start_psymtab_common (objfile=0xe4b530, 
    section_offsets=0xe26f80, filename=<optimized out>, textlow=0, 
    global_syms=0xf57178, static_syms=0xf6d930) at ../../gdb/psymtab.c:1325
#3  0x00000000005af17c in process_psymtab_comp_unit (objfile=0xe4b530, 
    this_cu=0xf20e00, buffer=0x7ffff5f7f033 "q", 
    info_ptr=0x7ffff603b279 "\002\024)", buffer_size=<optimized out>)
    at ../../gdb/dwarf2read.c:3267
#4  0x00000000005af57f in dwarf2_build_psymtabs_hard (objfile=0xe4b530)
    at ../../gdb/dwarf2read.c:3455
#5  dwarf2_build_psymtabs (objfile=0xe4b530) at ../../gdb/dwarf2read.c:2800
#6  0x00000000005af799 in dwarf2_initialize_objfile (objfile=0xe4b530)
    at ../../gdb/dwarf2read.c:2784


I suggest to fix this in read_indirect_string, dropping this strange
special-casing of '\0'.


At the moment I can only provide a 1GB core file plus binary / debug info
as testcase.  I will try to investigate where that odd debuginfo came from
though.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]