[COMMITTED] libdw: Check there is .debug_info/types section data in __libdw_offdie.
If a Dwarf_Die was requested from an offset into a section data that didn't exist we would crash. Crashing is bad even if given bad input. Just return an error in that case. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 4 libdw/dwarf_offdie.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index eb1cb709..97155de1 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2017-12-28 Mark Wielaard + + * dwarf_offdie.c (__libdw_offdie): Check sectiondata exists. + 2017-05-09 Ulf Hermann Mark Wielaard diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c index 15f55c22..883720de 100644 --- a/libdw/dwarf_offdie.c +++ b/libdw/dwarf_offdie.c @@ -1,5 +1,5 @@ /* Return DIE at given offset. - Copyright (C) 2002-2010 Red Hat, Inc. + Copyright (C) 2002-2010, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2002. @@ -45,7 +45,7 @@ __libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die *result, Elf_Data *const data = dbg->sectiondata[debug_types ? IDX_debug_types : IDX_debug_info]; - if (offset >= data->d_size) + if (data == NULL || offset >= data->d_size) { __libdw_seterrno (DWARF_E_INVALID_DWARF); return NULL; -- 2.14.3
[COMMITTED] readelf: Format offset as DIE index (hex).
That makes it so much easier to find the actual DIE offset in the output. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 + src/readelf.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 994b1e17..9d6ec830 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2017-12-28 Mark Wielaard + + * readelf.c (print_debug_units): Print DIE offset in error message + as hex. + 2017-12-18 Mark Wielaard * readelf.c (handle_notes_data): Don't use EXIT_FAILURE in error. diff --git a/src/readelf.c b/src/readelf.c index ca979e3c..ee9c7e1d 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6414,8 +6414,8 @@ print_debug_units (Dwfl_Module *dwflmod, if (unlikely (tag == DW_TAG_invalid)) { if (!silent) - error (0, 0, gettext ("cannot get tag of DIE at offset %" PRIu64 - " in section '%s': %s"), + error (0, 0, gettext ("cannot get tag of DIE at offset [%" PRIx64 + "] in section '%s': %s"), (uint64_t) offset, secname, dwarf_errmsg (-1)); goto do_return; } -- 2.14.3
Re: [PATCH] tests: Try to use coredumpctl to extract core files.
On Sun, Dec 24, 2017 at 04:10:45PM +0100, Mark Wielaard wrote: > On Sat, Dec 23, 2017 at 11:31:42PM +0100, Mark Wielaard wrote: > > If systemd-coredump is installed we have to use coredumpctl to extract > > the core file to test. Unfortunately systemd-coredump/coredumpctl seem > > to be somewhat fragile if multiple core dumps are generated/extracted > > at the same time. So use a lock file to only run one core dump test at > > a time (under make -j). > > One small addition to appease make distcheck. We have to clean up the > lock file. We don't want to make it a tempfile because we want the file > to exist globally during all test runs. I pushed this variant to master.