Menu

#529 libwarf aborts (assertion failure) if .debug_str section does not exist

RELEASE_1_0
new
nobody
None
2016-05-16
2016-05-16
Ed Maste
No

Identified in ticket #467

% findtextrel/findtextrel ticket-467/findtextrel/problems/samples/37239310 > /dev/null
findtextrel: ticket-467/findtextrel/problems/samples/37239310: elf_strptr() failed: Invalid argument
Assertion failed: (str != NULL), function _dwarf_attr_init, file libdwarf_attr.c, line 187.
zsh: abort (core dumped)  findtextrel/findtextrel ticket-467/findtextrel/problems/samples/37239310 > 

stack trace:

(lldb) bt
* thread #1: tid = 104267, 0x000000000045ccea findtextrel`thr_kill + 10 at thr_kill.S:3, stop reason = signal SIGABRT
  * frame #0: 0x000000000045ccea findtextrel`thr_kill + 10 at thr_kill.S:3
    frame #1: 0x000000000045ccd6 findtextrel`__raise(s=<unavailable>) + 38 at raise.c:51
    frame #2: 0x000000000045cc59 findtextrel`abort + 73 at abort.c:65
    frame #3: 0x00000000004631ea findtextrel`__assert(func=<unavailable>, file=<unavailable>, line=<unavailable>, failedexpr=<unavailable>) + 74 at assert.c:54
    frame #4: 0x000000000041b0c6 findtextrel`_dwarf_attr_init(dbg=0x0000000800c15080, ds=0x0000000800c078c0, offsetp=0x00007fffffffd730, dwarf_size=4, cu=0x0000000800c07920, die=0x0000000800c3c100, ad=0x0000000800c08060, form=14, indirect=0, error=0x00007fffffffda28) + 1270 at libdwarf_attr.c:187
    frame #5: 0x0000000000412cdd findtextrel`_dwarf_die_parse(dbg=0x0000000800c15080, ds=0x0000000800c078c0, cu=0x0000000800c07920, dwarf_size=4, offset=16, next_offset=144, ret_die=0x00007fffffffde48, search_sibling=0, error=0x00007fffffffda28) + 525 at libdwarf_die.c:146
    frame #6: 0x0000000000403237 findtextrel`_dwarf_search_die_within_cu(dbg=0x0000000800c15080, s=0x0000000800c078c0, cu=0x0000000800c07920, offset=11, ret_die=0x00007fffffffde48, error=0x00007fffffffda28) + 183 at dwarf_die.c:153
    frame #7: 0x0000000000402e91 findtextrel`dwarf_offdie_b(dbg=0x0000000800c15080, offset=11, is_info=1, ret_die=0x00007fffffffde48, error=0x00007fffffffda28) + 289 at dwarf_die.c:176
    frame #8: 0x0000000000402bbe findtextrel`dwarf_siblingof_b(dbg=0x0000000800c15080, die=0x0000000000000000, ret_die=0x00007fffffffde48, is_info=1, error=0x00007fffffffda28) + 318 at dwarf_die.c:90
    frame #9: 0x0000000000403174 findtextrel`dwarf_siblingof(dbg=0x0000000800c15080, die=0x0000000000000000, ret_die=0x00007fffffffde48, error=0x00007fffffffda28) + 52 at dwarf_die.c:143
    frame #10: 0x00000000004010dc findtextrel`report_textrel(fn=0x00007fffffffe82e, e=0x0000000800c060c0, dbg=0x0000000800c15080, off=0, textrel=0x00007fffffffdf9c) + 748 at findtextrel.c:169
    frame #11: 0x0000000000400db5 findtextrel`examine_reloc(fn=0x00007fffffffe82e, e=0x0000000800c060c0, d=0x0000000800c09240, sh=0x00007fffffffe3d0, ph=0x0000000800c0a1c0, phnum=2, dbg=0x0000000800c15080, textrel=0x00007fffffffdf9c) + 581 at findtextrel.c:277
    frame #12: 0x0000000000400a5b findtextrel`find_textrel(fn=0x00007fffffffe82e) + 1147 at findtextrel.c:374
    frame #13: 0x0000000000400534 findtextrel`main(argc=1, argv=0x00007fffffffe520) + 292 at findtextrel.c:419
    frame #14: 0x000000000040030f findtextrel`_start(ap=<unavailable>, cleanup=<unavailable>) + 367 at crt1.c:78
(lldb) frame sel 4
frame #4: 0x000000000041b0c6 findtextrel`_dwarf_attr_init(dbg=0x0000000800c15080, ds=0x0000000800c078c0, offsetp=0x00007fffffffd730, dwarf_size=4, cu=0x0000000800c07920, die=0x0000000800c3c100, ad=0x0000000800c08060, form=14, indirect=0, error=0x00007fffffffda28) + 1270 at libdwarf_attr.c:187
   184          case DW_FORM_strp:
   185                  atref.u[0].u64 = dbg->read(ds->ds_data, offsetp, dwarf_size);
   186                  str = _dwarf_find_section(dbg, ".debug_str");
-> 187                  assert(str != NULL);
   188                  atref.u[1].s = (char *) str->ds_data + atref.u[0].u64;
   189                  break;
   190          case DW_FORM_ref_sig8:

Failure to find the .debug_str section is an error of the input file, not a programming error in the libdwarf library, and should not abort.

Discussion


Log in to post a comment.