Bug 239516

Summary: readelf -wf segfaults on most (all?) debug info files
Product: Base System Reporter: Mark Johnston <markj>
Component: binAssignee: freebsd-bugs mailing list <bugs>
Status: New ---    
Severity: Affects Only Me CC: emaste, me
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Proposed patch
none
Robustness patch none

Description Mark Johnston freebsd_committer 2019-07-29 19:25:15 UTC
> readelf -wf /usr/lib/debug/bin/cat.debug 

The section .eh_frame contains:

Segmentation fault (core dumped)
>
Comment 1 Paco Pascal 2019-08-24 07:39:16 UTC
Created attachment 206840 [details]
Proposed patch
Comment 2 Paco Pascal 2019-08-24 23:14:54 UTC
Created attachment 206867 [details]
Robustness patch

Adding logic similar to the "robustness patch" I provided may be worthwhile. If another programmer using libdwarf makes a similar mistake, having it fail gracefully may be preferable over a segfault. For example, running readelf without the "proposed patch" would yield:


$ readelf -wf /usr/lib/debug/bin/cat.debug

The section .eh_frame contains:

Assertion failed: (ds->ds_data != NULL), function _dwarf_frame_section_init, file /usr/src/contrib/elftoolchain/libdwarf/libdwarf_frame.c, line 465.
Abort trap
$