Re: [DynInst_API:] PatchFunction blocks() crash


Date: Wed, 11 Mar 2015 11:00:24 -0500
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] PatchFunction blocks() crash
On 03/10/2015 08:26 PM, Donghai wrote:
Hi,

I use a very simple program to test the first example of PatchAPI.

Unfortunately, the dyninst gets crash on this example. More

specifically, func->blocks() cause the system segment fault.

The code is pasted as follows, can someone give me some hint?

Thanks.

Can you send us a stack trace from gdb of the fault?

It seems likely that some of our parseAPI optimizations are not playing nicely with this example, and that we're assuming data structures are populated before they actually are. If adding co->parse() before you create the PatchObject eliminates the crash, that's a good way to check whether we're being inappropriately lazy.


Best
Hai

ParseAPI::SymtabCodeSource *sts;
ParseAPI::CodeObject *co;
Address code_base = 0x8048000;

sts = new ParseAPI::SymtabCodeSource( argv[1] );
co = new ParseAPI::CodeObject( sts );

PatchObject *obj = PatchObject::create(co, code_base);

// Find all functions in the object
std::vector<PatchFunction*> all;
obj->funcs(back_inserter(all));

for (std::vector<PatchFunction*>::iterator fi = all.begin();
      fi != all.end(); fi++) {
   // Print out each function's name
   PatchFunction* func = *fi;
   std::cout << func->name() << std::endl;

   const PatchFunction::Blockset& blks = func->blocks();
   for (PatchFunction::BlockSet::iterator bi = blks.begin();
        bi != blks.end(); bi++) {
     // Print out each block's size
     PatchBlock* blk = *bi;
     std::cout << "\tBlock size:" << blk->size() << std::endl;
   }
}


_______________________________________________
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→]