[Soot-list] PatchingChain.insertBefore(Chain<E> toInsert, E point): bug?

Khilan Gudka khilan at doc.ic.ac.uk
Sat Dec 12 17:15:32 EST 2009


Hi,

Sorry, my description of the problem was incorrect. All jumps to "point"
from any unit in the chain are redirected to the first unit in the chain.

Khilan

2009/12/12 Khilan Gudka <khilan at doc.ic.ac.uk>

> Hi Eric,
>
> I've just come across another issue, which the previous fix doesn't solve.
> If the first unit u of the chain being inserted itself points to "point",
> then the code still results in u then pointing to u. For example, inserting
>
> label0:
> if (x == 0) goto label1;
>
> before
> label1:
> nop
>
> would lead to:
>
> label0:
> if (x == 0) goto label0;
>
> label1:
> nop
>
> I had a look and found that AbstractUnit.redirectJumpsToThisTo(Unit
> newLocation) does not check if the jump source is itself "newLocation." Is
> this the intended behaviour?
>
> What do you suggest?
>
> Thanks,
> Khilan
>
> 2009/12/10 Eric Bodden <bodden at st.informatik.tu-darmstadt.de>
>
>> Seems to cause no problems... This is now committed in revision 3351.
>>
>> Thanks again,
>> Eric
>>
>> --
>> Eric Bodden
>> Software Technology Group, Technische Universität Darmstadt, Germany
>> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>>
>>
>>
>> 2009/12/10 Eric Bodden <bodden at st.informatik.tu-darmstadt.de>:
>> > Hi Khilan.
>> >
>> > Thanks for the patch. This looks like a correct patch to an actual bug
>> > to me. I will try it out with our test suite today.
>> > Eric
>> >
>> > --
>> > Eric Bodden
>> > Software Technology Group, Technische Universität Darmstadt, Germany
>> > Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> > Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>> >
>> >
>> >
>> > 2009/12/9 Khilan Gudka <khilan at doc.ic.ac.uk>:
>> >> Hi,
>> >> The method PatchingChain.insertBefore(Chain<E> toInsert, E point)
>> inserts
>> >> the chain "toInsert" just before "point" in the receiver chain. It does
>> this
>> >> by calling PatchingChain.insertBefore(E toInsert, E point) for each
>> Unit in
>> >> a reversed version of toInsert. To keep the correct control flow,
>> >> PatchingChain.insertBefore(E toInsert, E point) redirects jumps to
>> "point"
>> >> to jump to "toInsert" instead. However, I've found that this leads to
>> bugs
>> >> when inserting a chain that contains jumps itself. For example,
>> inserting
>> >> the jimple code:
>> >>         if $r == 0 goto label0;
>> >>         staticinvoke <mypackage.MyClass: void m()>();
>> >>      label0:
>> >>         staticinvoke <mypackage.MyClass: void n()>();
>> >> Which corresponds to:
>> >> if($r) {
>> >>     MyClass.m();
>> >> }
>> >> MyClass.n();
>> >> Would be turned into the following when using the
>> >> above PatchingChain.insertBefore(Chain<E> toInsert, E point) method:
>> >>      label0:
>> >>         if $r == 0 goto label0;
>> >>         staticinvoke <mypackage.MyClass: void m()>();
>> >>         staticinvoke <mypackage.MyClass: void n()>();
>> >> The reason being that when insertBefore(E toInsert, E point) is
>> repeatedly
>> >> called, the jump to "staticinvoke <mypackage.MyClass: void n()>();" is
>> >> redirected to the first statement "if $r == 0 goto label0;".
>> >> I think the solution is to, lastly, redirect jumps to "point" to the
>> first
>> >> unit in toInsert (here is a snippet from the bottom
>> >> of PatchingChain.insertBefore(Chain<E> toInsert, E point) and the
>> proposed
>> >> changes are in bold):
>> >>         E previousPoint = point;
>> >>         Iterator<E> it = backwardList.iterator();
>> >>         while (it.hasNext())
>> >>         {
>> >>             E o = it.next();
>> >>             insertBeforeNoRedirect(o, previousPoint);
>> >>             previousPoint = o;
>> >>         }
>> >>         ((Unit) point).redirectJumpsToThisTo((Unit)
>> toInsert.getFirst());
>> >> Does this make sense or have I overlooked something?
>> >> Thanks,
>> >> Khilan
>> >> _______________________________________________
>> >> Soot-list mailing list
>> >> Soot-list at sable.mcgill.ca
>> >> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >>
>> >>
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20091212/df24ca64/attachment.html 


More information about the Soot-list mailing list