Re: [DynInst_API:] SymtabAPI segmentation fault


Date: Tue, 08 Jan 2019 09:50:03 -0600
From: Xiaozhu Meng <mxz297@xxxxxxxxx>
Subject: Re: [DynInst_API:] SymtabAPI segmentation fault
Thanks for the update.

Before you call Instruction::getReadSet(), can you first call Instruction::isValid()? Instruction::isValid() returns a boolean representing whether this is a valid instruction. I guess the problem here is that Dyninst wrongly decodes a valid instruction into an invalid instruction. And then when you try get registers from an invalid instruction, Dyninst did not handle such corner case properly and asserted.Â

If there is indeed invalid instructions reported by Dyninst, can you share the binary with me so that I can continue to fix the instruction decoding?

Thanks,

--XiaozhuÂ

On Tue, Jan 8, 2019 at 9:32 AM Buddhika Chamith Kahawitage Don <budkahaw@xxxxxx> wrote:
Also when I checked the f->region()->geArch() parameter passed to the decoder it showed me Dyninst::Arch_x86_64.

On Tue, Jan 8, 2019 at 9:00 PM Buddhika Chamith Kahawitage Don <budkahaw@xxxxxx> wrote:
I retired with Dyninst 10.0.0. Now I get the following

RegAudit: /home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/InstructionDecoderImpl.C:77: static Dyninst::InstructionAPI::InstructionDecoderImpl::Ptr Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl(Dyninst::Architecture): Assertion `0' failed.

Thread 1 "RegAudit" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51ÂÂÂ ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0Â __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1Â 0x00007ffff639b801 in __GI_abort () at abort.c:79
#2Â 0x00007ffff638b39a in __assert_fail_base (fmt=0x7ffff65127d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
ÂÂÂ assertion=assertion@entry=0x7ffff73f2a48 "0",
ÂÂÂ file=file@entry=0x7ffff73fbc00 "/home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/InstructionDecoderImpl.C", line=line@entry=77,
ÂÂÂ function=function@entry=0x7ffff73fc180 <Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl(Dyninst::Architecture)::__PRETTY_FUNCTION__> "static Dyninst::InstructionAPI::InstructionDecoderImpl::Ptr Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl(Dyninst::Architecture)") at assert.c:92
#3Â 0x00007ffff638b412 in __GI___assert_fail (assertion=assertion@entry=0x7ffff73f2a48 "0",
ÂÂÂ file=file@entry=0x7ffff73fbc00 "/home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/InstructionDecoderImpl.C", line=line@entry=77,
ÂÂÂ function=function@entry=0x7ffff73fc180 <Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl(Dyninst::Architecture)::__PRETTY_FUNCTION__> "static Dyninst::InstructionAPI::InstructionDecoderImpl::Ptr Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl(Dyninst::Architecture)") at assert.c:101
#4Â 0x00007ffff73f0d56 in Dyninst::InstructionAPI::InstructionDecoderImpl::makeDecoderImpl (
ÂÂÂ a=a@entry=Dyninst::Arch_none)
ÂÂÂ at /home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/InstructionDecoderImpl.C:77
#5Â 0x00007ffff7277644 in Dyninst::InstructionAPI::InstructionDecoder::InstructionDecoder (this=0x7fffffffd210,
ÂÂÂ buffer=<optimized out>, size=<optimized out>, arch=Dyninst::Arch_none)
ÂÂÂ at /home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/InstructionDecoder.C:49
#6Â 0x00007ffff72533a8 in Dyninst::InstructionAPI::Instruction::decodeOperands (this=0x7fffffffd540)
ÂÂÂ at /home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/Instruction.C:120
#7Â 0x00007ffff72554d5 in Dyninst::InstructionAPI::Instruction::getReadSet (this=0x7fffffffd540,
ÂÂÂ regsRead=std::set with 0 elements) at /home/buddhika/Builds/dyninst-10.0.0/instructionAPI/src/Instruction.C:288
#8Â 0x0000555555559025 in main (argc=2, argv=0x7fffffffd968) at RegAudit.cpp:178

Looks like it didn't pick up the Architecture looking at InstructionDecoderImpl.C? I create the InstructionDecoder as below.

ÂÂÂ Function* f; // Get function from CodeObject->funcs()
ÂÂÂ InstructionDecoder decoder(f->isrc()->getPtrToInstruction(f->addr()),
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ InstructionDecoder::maxInstructionLength,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ f->region()->getArch());

Any ideas?

Cheers

On Tue, Jan 8, 2019 at 5:34 PM Buddhika Chamith Kahawitage Don <budkahaw@xxxxxx> wrote:
Sure. I will update and report back.

Thanks
Buddhika

On Mon, Jan 7, 2019 at 8:45 PM Xiaozhu Meng <mxz297@xxxxxxxxx> wrote:
Hi,

Can you upgrade to use Dyninst 10.0.0? Dyninst 10 contains many bug fixes and new features over 9.3.2, but you will need to use libdw-0.173. If the same problem shows up, please let me know and I will take a look at it.

Thanks,

--Xiaozhu

On Sat, Jan 5, 2019 at 9:56 PM Buddhika Chamith Kahawitage Don <budkahaw@xxxxxx> wrote:
Hi,

I am trying to use SymtabAPI to analyze the register usage of a binary. My implementation fails on some binaries (built with -g) with below stack trace.

I have installed libdw-0.170 on my system using Ubuntu package manager. Does this look familiar?


#0Â Dyninst::SymtabAPI::DwarfWalker::findDieName (dbg=dbg@entry=0x5555557be3c0, die=0x5555559b3840, name="")
ÂÂÂ at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/dwarfWalker.C:1448
#1Â 0x00007ffff7226767 in Dyninst::SymtabAPI::Object::dwarf_parse_aranges (this=this@entry=0x5555557b6440,
ÂÂÂ dbg=dbg@entry=0x5555557be3c0, dies_seen=std::set with 0 elements)
ÂÂÂ at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Object-elf.C:2461
#2Â 0x00007ffff7226b75 in Dyninst::SymtabAPI::Object::fix_global_symbol_modules_static_dwarf (
ÂÂÂ this=this@entry=0x5555557b6440) at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Object-elf.C:2490
#3Â 0x00007ffff7229ab4 in Dyninst::SymtabAPI::Object::load_object (this=this@entry=0x5555557b6440,
ÂÂÂ alloc_syms=alloc_syms@entry=true) at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Object-elf.C:1602
#4Â 0x00007ffff722aa1e in Dyninst::SymtabAPI::Object::Object (this=0x5555557b6440, mf_=0x5555557b0460,
ÂÂÂ err_func=<optimized out>, alloc_syms=<optimized out>, st=<optimized out>)
ÂÂÂ at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Object-elf.C:2967
#5Â 0x00007ffff71e63d3 in Dyninst::SymtabAPI::Symtab::Symtab (this=0x5555557b5230, filename="",
ÂÂÂ defensive_bin=<optimized out>, err=@0x7fffffffd61f: false)
ÂÂÂ at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Symtab.C:1261
#6Â 0x00007ffff71e68d1 in Dyninst::SymtabAPI::Symtab::openFile (obj=@0x7fffffffd6a0: 0x0, filename="CG",
ÂÂÂ def_binary=Dyninst::SymtabAPI::Symtab::NotDefensive)
ÂÂÂ at /home/buddhika/Builds/dyninst-9.3.2/symtabAPI/src/Symtab.C:2077


Regards
Buddhika
_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
[← Prev in Thread] Current Thread [Next in Thread→]