[Soot-list] Possible bug with null-type locals

Rohan Padhye rohanpadhye at cse.iitb.ac.in
Mon Mar 4 08:32:21 EST 2013


Hi,

I have come across what seems to be a bug in the nightly build.

Consider a simple program constructing a linked-list of five elements:

class Node
{
     Node n;
}
class BugTest
{
     public static void main(String args[])
     {
         Node x = null;
         for(int i=0; i<5; i++) {
             Node t = new Node();
             t.n = x;
             x = t;
         }
     }
}


For some reason Soot builds the following Jimple: (Note the Jimple for 
the line "t.n = x")

public static void main(java.lang.String[])
     {
         java.lang.String[] r0;
         null_type n0;
         byte b0;
         Node r1, $r2, r3;
         int i1;

         r0 := @parameter0: java.lang.String[];
         n0 = null;
         b0 = 0;

      label0:
         if b0 >= 5 goto label1;

         $r2 = new Node;
         specialinvoke $r2.<Node: void <init>()>();
         r1 = $r2;
         r1.<Node: Node n> = n0;      // <-----------------------
         r3 = r1;
         i1 = b0 + 1;
         goto label0;

      label1:
         return;
     }

Notice that "t.n = x" has essentially turned to "t.n = null". This is 
not some optimization as I have acquired this dump right after
the Jimple body creation phase. The optimized Jimple gets away with the 
loop altogether which is even stranger.

Oh, and it is not because I am not using the linked list later, which 
makes it dead, or something like that.
This behaviour is observed even in larger programs where I am actively 
using the list.

This problem did not occur in the last build I used (Jan 26), but is 
occurring in the current one.

Regards,

Rohan


More information about the Soot-list mailing list