Re: [DynInst_API:] InstructionAPI segfault on archive files


Date: Wed, 08 Jul 2015 10:31:16 -0500
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] InstructionAPI segfault on archive files
On 07/05/2015 02:22 PM, Alin Mîndroc wrote:
Hi everyone,

I am using DyninstAPI for a project involving disassembling files, and
it worked perfectly until I had to use it on archive files (static
libraries .a).

When I try to get the assembly code for librt.a, a segfault is raised
inside the "ia32_decode_prefixes" method. The strange thing is that it
fails for a "call" instruction (hex code e8 00 00 00 00), which was
already parsed successfully before in another function.

Currently, my way of getting assembly code for a function is to
instantiate a decoder:
decoder(currentFunction->isrc()->getPtrToInstruction(crtaddr),
InstructionDecoder::maxInstructionLength,
currentFunction->isrc()->getArch());
Where crtaddr is (last instruction address) + (last instruction size)
Then, the segfault is thrown for the "call" instruction when I call the
decode() method on this InstructionDecoder instance.

Any hints on this? Is there any other way of getting assembly code for
an archive file?

I'd valgrind this. It sounds to me like either your decode buffer has gone away somehow or you've overrun it; max instruction length could in fact hit a buffer overrun at the end of a mapped-in file.

If you're just doing a linear scan disassemble, you can create a decoder with the full size of the buffer and iteratively decode; that's a safer approach (assuming that your problem is in fact a buffer overrun).

Thanks,
Alin


_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api



--
--bw

Bill Williams
Paradyn Project
bill@xxxxxxxxxxx
[← Prev in Thread] Current Thread [Next in Thread→]