[Soot-list] Possible bug in PatchingChain.insertBefore(List, Object)

mbatch at cs.mcgill.ca mbatch at cs.mcgill.ca
Wed May 31 20:48:10 EDT 2006


> I have an idea that might partially explain this: some of the code I'm
> inserting contains jumps to 'point' that I want to keep intact after
> they're inserted. For example, say this block of code, 'toInsert', is a
> while loop that I've constructed. Before I insert the while loop, I've set
> the target of the if statement at the top, which represents the loop
> condition, to the same 'point' that I'm passing to insertBefore(), so that
> it exits properly when this loop is inserted into the method.
> insertBefore() now redirects the if statement's target, so that if the
> loop condition fails, it just jumps back to the loop condition again, so
> you have an infinite loop.

You can always use insertAfter and redirect jumps yourself or insert
before and make sure to go back through those units you added and "fix"
the jumps.

The insertBefore(List toInsert, Unit point) method which takes a list to
insert reverses that list and then calls the other insertBefore(Unit
insert, Unit point) for each element in the list.. obviously this will
redirect any jumps that get added before the last (first) element.

Also, just FYI, you can have an intermediate unit chain that is not
"proper" (i.e. will fail the verifier, etc) as long as it is proper once
it exits the phase and is dumped out to bytecode.

Michael



More information about the Soot-list mailing list