[Soot-list] Loop Finder: Identify Synchronized Block as Loops

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Tue Aug 18 10:04:26 EDT 2009


This seems to be a (known?) bug in Soot with respect to synchronized
blocks. Soot generates for this snippet...

    public TestLoop() throws Exception {

        synchronized (System.out) {
            ;
        }

    }

... the following Jimple code:

...
     label0:
        nop;
        exitmonitor temp$0;
        goto label2;

     label1:
        nop;
        temp$1 := @caughtexception;
        exitmonitor temp$0;
        throw temp$1;

     label2:
        nop;
        return;

        catch java.lang.Throwable from label0 to label2 with label1;

The problem is here the catch clause at the end. I think it should
read "from label0 to label1 with label1" instead. The way it's wired
up right now, there is indeed an exceptional flow edge from anything
between label1 and label2 back to label1, which yields a loop.

I think Patrick Lam tried to fix this a while ago but his fix was
invalid. I guess we will have to look into this again. (It's less
trivial than one might think because that code in Soot is quite old
and nobody seems to know any more quite how it works. :-))

Eric

2009/8/18 Kelvin Tian <kevinn.tian at gmail.com>:
> OK, sure. Here's a simple test example. To see the result, just use the
> LoopFinder to transform it.  Thanks for the consistent help.
>
>
> class TestLoop {
>
>     public TestLoop() throws Exception {
>
>         synchronized (System.out) {
>             ;
>         }
>         synchronized (System.err) {
>             ;
>         }
>
>     }
>
>
>     public static void main(String[] args) {
>
>         int loopcnt = 0;
>
>         for (int i = 0; i < 5; i++) {
>             int j=0;
>
>             while(j<3){
>                 loopcnt++;
>                 j++;
>             }
>         }
>     }
>
> }
>
>
>
> --
> Best regards,
> Kelvin
>
>
>
> On Tue, Aug 18, 2009 at 2:27 AM, Eric Bodden
> <bodden at st.informatik.tu-darmstadt.de> wrote:
>>
>> Hi Kelvin.
>>
>> This sounds like a bug to me. There is certainly no transformation
>> into loops as you describe it.
>>
>> Can you please send a minimal example to the list where this occurs?
>>
>> Eric
>>
>> 2009/8/17 Kelvin Tian <kevinn.tian at gmail.com>:
>> > Hi,
>> >
>> >      I need to collect some profiling information based on loops, and I
>> > reused the LoopFinder class to find loops, but when I tried to collect
>> > some
>> > information from the Dacapo benchmark, I found a lot of problems. One
>> > major
>> > problem is that LoopFinder always took synchronized block as multiple
>> > loops
>> > (normally 3 loops from one synchronized block).  Is this a possible bug
>> > or
>> > Synchronized block is translated to be some kind of loops in Soot?
>> >
>> >
>> > --
>> > Best regards,
>> > Kelvin
>> >
>> >
>> > _______________________________________________
>> > Soot-list mailing list
>> > Soot-list at sable.mcgill.ca
>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >
>> >
>>
>>
>>
>> --
>> Eric Bodden
>> Software Technology Group
>> Technical University Darmstadt, Germany
>
>



-- 
Eric Bodden
Software Technology Group
Technical University Darmstadt, Germany


More information about the Soot-list mailing list