Bug 239516 - readelf -wf segfaults on most (all?) debug info files
Summary: readelf -wf segfaults on most (all?) debug info files
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2019-07-29 19:25 UTC by Mark Johnston
Modified: 2019-08-24 23:14 UTC (History)
2 users (show)

See Also:


Attachments
Proposed patch (533 bytes, patch)
2019-08-24 07:39 UTC, Paco Pascal
no flags Details | Diff
Robustness patch (542 bytes, patch)
2019-08-24 23:14 UTC, Paco Pascal
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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
$