Re: [DynInst_API:] symtab openfile still segfaults with old libelf


Date: Mon, 21 Nov 2016 17:04:08 +0000
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] symtab openfile still segfaults with old libelf
Yeah, those commits don't do it either and I've only succeeded in moving the segfault around. Libelf.so.0 is not playing nicely with the data translation functions even when I do things nominally out-of-line.

I think we're at the point where the right answer is to get onto elfutils: https://github.com/dyninst/dyninst/issues/242. This will, at the least, make the fine folks at RedHat happy and possibly encourage them to do useful work with libdw. I'll be sure to update the docs and the CMake auto-download so we're not setting traps for the unwary user.

--bw

________________________________________
From: Mark W. Krentel <krentel@xxxxxxxx>
Sent: Sunday, November 20, 2016 1:30 PM
To: dyninst-api@xxxxxxxxxxx; Bill Williams
Subject: symtab openfile still segfaults with old libelf

Bill,

Did you indicate that the fix for using the old libelf was merged into
master?  I'm still seeing the same problem.

I just tried this version from master.

commit 64edc81ee01131502e2568749f006e3511c44fb6
Merge: d747211 3c12b19
Author: Bill Williams <wwilliam47@xxxxxxxxx>
Date:   Tue Nov 15 15:43:38 2016 -0700

     Merge pull request #205 from dyninst/dync_windows

And I do see earlier commits that are predecessors to this one that
claim to have fixed the problem.

commit bd7c304b59e39408f31969a578138941205d6fec
Author: Bill Williams <bill@xxxxxxxxxxx>
Date:   Thu Nov 10 14:01:07 2016 -0600

     Fix for broken libelfs that can't handle translate-in-place on
Elf_Data.

M       elf/src/Elf_X.C

But with the same test program, just call Symtab::openFile(), I still
get the same segfault.

#0  0x00007f7d37f6b853 in Dyninst::Elf_X_Data::d_buf
(this=this@entry=0x7fff7917a4e0)
     at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/elf/src/Elf_X.C:832

#1  0x00007f7d384288b9 in Dyninst::SymtabAPI::Object::loaded_elf
(this=this@entry=0x17aa130,
     txtaddr=txtaddr@entry=@0x7fff7917a6f0: 0,
dataddr=dataddr@entry=@0x7fff7917a6f8: 0, bssscnp=@0x7fff7917a6b8: 0x0,
     symscnp=@0x7fff7917a6c0: 0x0, strscnp=@0x7fff7917a6c8: 0x0,
stabscnp=@0x7fff7917a6d0: 0x0,
     stabstrscnp=@0x7fff7917a6d8: 0x0, stabs_indxcnp=@0x7fff7917a6e0:
0x0, stabstrs_indxcnp=@0x7fff7917a6e8: 0x0,
     rel_plt_scnp=@0x7fff7917a700: 0x0, plt_scnp=@0x7fff7917a708: 0x0,
got_scnp=@0x7fff7917a710: 0x0,
     dynsym_scnp=@0x7fff7917a718: 0x0, dynstr_scnp=@0x7fff7917a720: 0x0,
dynamic_scnp=@0x7fff7917a728: 0x0,
     eh_frame=@0x7fff7917a730: 0x0, gcc_except=@0x7fff7917a738: 0x0,
interp_scnp=@0x7fff7917a740: 0x0,
     opd_scnp=@0x7fff7917a748: 0x0) at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/symtabAPI/src/Object-elf.C:655

#2  0x00007f7d3842d9d3 in Dyninst::SymtabAPI::Object::load_object
(this=this@entry=0x17aa130,
     alloc_syms=alloc_syms@entry=true)
     at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/symtabAPI/src/Object-elf.C:1524

#3  0x00007f7d3842eddc in Dyninst::SymtabAPI::Object::Object
(this=0x17aa130, mf_=0x17aa0e0, err_func=<optimized out>,
     alloc_syms=<optimized out>, st=<optimized out>)
     at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/symtabAPI/src/Object-elf.C:2927

#4  0x00007f7d383ea392 in Dyninst::SymtabAPI::Symtab::Symtab
(this=0x17a8ec0,
     filename="\250\216z\001\000\000\000\000\250\216z\001", '\000'
<repeats 12 times>,
"C\276\027y\377\177\000\000\002\000\000\000\000\000\000\000\304\377\377\377\000\000\000\000\260\252\027y\377\177\000\000\002\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\022\021@\000\000\000\000\000\b\023@\000\000\000\000\000\250\252\027y\377\177\000\000\250\216z\001\000\000\000\000\002\000\000\000\000\000\000\000\250\216z\001\000\000\000\000l\022@\000\000\000\000\000\250\216z\001\000\000\000\000\315\022@\000\000\000\000\000\360M\367\070}\177",
'\000' <repeats 18 times>,
"\200\016@\000\000\000\000\000\240\252\027y\377\177", '\000' <repeats 18
times>...<Address 0x7fff7917d000 out of bounds>,
defensive_bin=<optimized out>,
     err=@0x7fff7917a8fe: false) at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/symtabAPI/src/Symtab.C:1270

#5  0x00007f7d383ea837 in Dyninst::SymtabAPI::Symtab::openFile
(obj=@0x602228: 0x0, filename="inline",
def_binary=def_binary@entry=Dyninst::SymtabAPI::Symtab::NotDefensive)
     at
/home/krentel/newelf/externals/BUILD/symtabAPI/dyninst/symtabAPI/src/Symtab.C:2102

#6  0x0000000000401112 in main (argc=2, argv=0x7fff7917aaa8) at
inline.cpp:276


Am I building something wrong here?  It looks to me like the fix is
incomplete.  See if you can reproduce the problem with the current
version of master and old libelf-0.8.13.

Long term, this won't matter for our purposes.  I'm working on
switching to elfutils.  There are a few annoying technical issues, so
it's not quite as simple as I had hoped and I'm not quite yet finished.

So, you could just wait me out.  Pretty soon, I'll upgrade to elfutils
and then you won't hear more bug reports from me.  :-)

I looked over a few systems and it looks like everyone else has
switched to elfutils a long time ago.  So, if you want to drop support
for older libelf, I'm mostly ok with that.  Just be sure to put it in
the release notes.

--Mark


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