Re: [DynInst_API:] segfault when trying to parse an ELF, dereferencing [0] in vector of size 0


Date: Thu, 11 Jan 2018 11:45:13 +0100
From: Thomas Dullien <thomasdullien@xxxxxxxxxx>
Subject: Re: [DynInst_API:] segfault when trying to parse an ELF, dereferencing [0] in vector of size 0
Hey there,

a quick update: The issue seems to be that the ELF file has legitimate shdrnum=0 in the header,
which some of the other code is not prepared for.

Cheers,
Thomas

On Thu, Jan 11, 2018 at 11:36 AM, Thomas Dullien <thomasdullien@xxxxxxxxxx> wrote:
Hey there,

I am trying to run a particular ELF file through Dyninst, but I get a segfault
in Elf_X.C:

if (!shdrs[i]._elf) {ÂÂ

The trouble is that shdrs is an empty vector, and i is 0, so we can't dereference
at index 0.

#0Â Dyninst::Elf_X::get_shdr (this=this@entry=0x557c15ecf0a0, i=0) at /home/thomasdullien/Desktop/sources/dyninst/dyninst/elf/src/Elf_X.C:473
#1Â 0x00007fd72b83f43a in Dyninst::Elf_X::findDebugFile (this=0x557c15ecf0a0, origfilename="/home/thomasdullien/Downloads/foo.elf", output_name="", output_buffer=@0x7fff5398c320: 0x557c15ecf470 "/home/thomasdullien/Downloads/foo.elf", output_buffer_size=@0x7fff5398c
328: 93991432156048) at /home/thomasdullien/Desktop/sources/dyninst/dyninst/elf/src/Elf_X.C:1659
#2Â 0x00007fd72ba5b124 in Dyninst::Dwarf::DwarfHandle::locate_dbg_file (this=this@entry=0x557c15ecf3d0) at /home/thomasdullien/Desktop/sources/dyninst/dyninst/dwarf/src/dwarfHandle.C:80
#3Â 0x00007fd72ba5b29f in Dyninst::Dwarf::DwarfHandle::DwarfHandle (this=0x557c15ecf3d0, filename_=..., file_=<optimized out>, err_func_=<optimized out>) at /home/thomasdullien/Desktop/sources/dyninst/dyninst/dwarf/src/dwarfHandle.C:73
#4Â 0x00007fd72ba5b9ff in Dyninst::Dwarf::DwarfHandle::createDwarfHandle (filename_="/home/thomasdullien/Downloads/foo.elf", file_=file_@entry=0x557c15ecf0a0, err_func_=err_func_@entry=0x7fd72ba5b010 <Dyninst::Dwarf::DwarfHandle::defaultDwarfError(Dwarf_Error_s*, void*
)>) at /home/thomasdullien/Desktop/sources/dyninst/dyninst/dwarf/src/dwarfHandle.C:249

Shall I try to dig further, or should this be sufficient to find the problem?

Cheers & keep up the good work :-)
Thomas


[← Prev in Thread] Current Thread [Next in Thread→]