[Soot-list] Incomplete Call Graph with paddle in case of multi threaded program

Eric Bodden eric.bodden at ec-spride.de
Mon Feb 11 12:26:27 EST 2013


Hello.

Thanks for trying this out. Could you please create a report in the
issue tracker and attach to it everything we need to reproduce this
problem?
https://github.com/Sable/soot/issues

Ideally you would check in an Eclipse project with your main driver
class, the test code you analyze and an appropriate run configuration.

Cheers,
Eric

On 11 February 2013 18:21, ASHISH MISHRA <ashish123.mishragkp at gmail.com> wrote:
> Hi Eric,
>
> Thanks for the reply, I tried running paddle in default mode -
> Following are the only Thread edges from the Call Graph in default mode.
>
> 1---THREAD edge: virtualinvoke t_1.<java.lang.Thread: void start()>() in
> <testcases.test_thread: void main(java.lang.String[])> ==>
> <java.lang.Thread: void run()>
>
> 2---THREAD edge: virtualinvoke t_2.<java.lang.Thread: void start()>() in
> <testcases.test_thread: void main(java.lang.String[])> ==>
> <java.lang.Thread: void run()>
>
> 3---THREAD edge: virtualinvoke l1.<java.lang.Thread: void start()>() in
> <java.lang.ref.Finalizer: void <clinit>()> ==>
> <java.lang.ref.Finalizer$FinalizerThread: void run()>
>
>
> As can be seen , thread edges 1 and 2 are edges from the main() to
> <java.lang.Thread>.run(), but no edge for main() to <MyThread>.run() .
> Shouldn't this Thread edge be available?, am I missing something serious or
> is there some problem with my understanding.
>
> regards
> Ashish
>
>
> On Mon, Feb 11, 2013 at 9:34 PM, Eric Bodden <eric.bodden at ec-spride.de>
> wrote:
>>
>> Hello.
>>
>> This is odd. I have definitely seen this work before, at least with Spark.
>>
>> Does the edge show up when you run paddle with its default options?
>>
>> Eric
>>
>> On 11 February 2013 14:37, ASHISH MISHRA <ashish123.mishragkp at gmail.com>
>> wrote:
>> > Dear all,
>> >
>> > I am trying to build Context sensitive call graph for a program
>> > involving
>> > threads. But I think the graph is missing the call Edge from main method
>> > to
>> > MyThread.run().
>> >
>> > 1) This is the case when I use Runnable interface for thread execution.
>> >
>> > 2) However for the other example program , where I execute threads via
>> > extending Thread class , the said edge is present.
>> >
>> > I am doing some thing like this-
>> >
>> > //My analysis code starts here//
>> >
>> > public class PaddleTest {
>> > public static void main(String[] args) {
>> > List<String> argList= new ArrayList<String>(Arrays.asList(args));
>> > String[] soot_options= new String[]{
>> > "-w",
>> > "-p",
>> > "jb",
>> > "use-original-names:true",
>> > "-p",
>> > "cg",
>> > "enabled:true",
>> > "-cp",
>> > ".",
>> > "-pp",
>> > "-main-class",
>> > args[0],
>> > "--app",
>> > args[0],
>> > "-f",
>> > "jimp"
>> > };
>> > argList.addAll(Arrays.asList(soot_options));
>> > PackManager.v().getPack("wjtp").add(
>> >    new Transform("wjtp.myTransform", new SceneTransformer() {
>> >      protected void internalTransform(String phase, Map options) {
>> >
>> >      CallGraph cg = null;
>> >      //set paddle options
>> >      HashMap opt = new HashMap();
>> >      opt.put("enabled","true");
>> >      opt.put("verbose","true");
>> >      opt.put("bdd","true");
>> >      opt.put("backend","buddy");
>> >      opt.put("context","kcfa");
>> >      opt.put("context-heap", "true");
>> >     // opt.put("context-counts","true");
>> >      opt.put("k","2");
>> >      opt.put("propagator","auto");
>> >      opt.put("conf","ofcg-aot");
>> >      opt.put("order","32");
>> >      opt.put("q","auto");
>> >      opt.put("set-impl","double");
>> >      opt.put("double-set-old","hybrid");
>> >      opt.put("double-set-new","hybrid");
>> >      opt.put("pre-jimplify","false");
>> >      opt.put("whole-program", "true");
>> >      PaddleTransformer pt = new PaddleTransformer();
>> >      PaddleOptions paddle_opt = new PaddleOptions(opt);
>> >      pt.setup(paddle_opt);
>> >      pt.solve(paddle_opt);
>> >      soot.jimple.paddle.Results.v().makeStandardSootResults();
>> >
>> >
>> >
>> >
>> >     cg= Scene.v().getCallGraph(); //return paddle call graph
>> >        //do your stuff here
>> >
>> >     System.out.println("The Call Graph size " + cg.size());
>> >
>> >     System.out.println("Call Graph" + cg.toString());
>> >
>> >                                         }
>> >   }));
>> >
>> > Scene.v().addBasicClass("java.lang.Process",SootClass.HIERARCHY);
>> > Scene.v().addBasicClass("java.io.FileSystem",SootClass.HIERARCHY);
>> > soot.Main.main(soot_options);
>> > }
>> >
>> > }
>> >
>> > INPUT - WHICH DOES NOT SHOW CALL EDGE main() ---->
>> >
>> > public class test_thread{
>> >
>> >     public static void main(String[] args) {
>> >
>> >     AliasClass obj = new AliasClass();
>> >     obj.twoDArray = new int[10][10]; // Allocate shared memory
>> >     Runnable myThread_obj1 = new MyThread(obj);
>> >     Runnable myThread_obj2 = new MyThread(obj);
>> >
>> >     // Both threads will access the same shared object of the
>> > AliasClass.
>> >     Thread t_1 = new Thread(myThread_obj1);
>> >     Thread t_2 = new Thread(myThread_obj2);
>> >     t_1.start();
>> >     t_2.start();
>> >     }
>> > }
>> >
>> >
>> > class AliasClass{
>> >     public int [][]twoDArray;
>> >     public AliasClass() {}
>> > }
>> >
>> >
>> >
>> > class MyThread implements Runnable{
>> >     public AliasClass sharedObj;
>> >
>> >     public MyThread(AliasClass paramObj) {
>> >     sharedObj = paramObj;
>> >     }
>> >
>> >
>> >
>> >     public void run() {
>> >
>> >     int [][]auxArr = sharedObj.twoDArray;
>> >     int []arr;
>> >     int j=0;
>> >
>> >     for(j=0; j<10; ++j) {
>> >         arr = new int[10];
>> >         auxArr[j] = arr;
>> >     }
>> >     }
>> > }
>> >
>> >
>> > CODE - WHICH HAS THE SAID EDGE-
>> >
>> >
>> > package testcases;
>> >
>> > import java.lang.Thread;
>> > import java.lang.Runnable;
>> >
>> > public class test_thread2{
>> >
>> >     public static void main(String[] args) {
>> >
>> >
>> >
>> >
>> >     Thread t_1 = new MyThread_et();
>> >
>> >     t_1.start();
>> >     }
>> > }
>> >
>> > class MyThread_et extends Thread{
>> > public MyThread_et(){ }
>> > //Override run
>> > public void run(){
>> > for(int i=0; i<10; i++){
>> > System.out.println("Iside Thread object");
>> > try{
>> > Thread.sleep(10);
>> > }catch (Exception e) {
>> > // TODO: handle exception
>> > }
>> > }
>> > }
>> > }
>> > }
>> >
>> >
>> > This problem is not a new one and has been reported earlier too in the
>> > list
>> > follow link, unfortunately remains unsolved .
>> >
>> > http://www.sable.mcgill.ca/pipermail/soot-list/2011-June/003722.html
>> >
>> >
>> > I looked at the paddle code but couldn't get the answer yes. Please help
>> > me
>> > on this.
>> >
>> >
>> >
>> > --
>> > Regards,
>> > Ashish Mishra
>> > Graduate Student,
>> > Computer Science and Automation Department,IISc
>> > Cell : +91-9611194714
>> > Mailto : ashishmishra at csa.iisc.ernet.in
>> >
>>
>>
>>
>> --
>> Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
>> Head of Secure Software Engineering Group at EC SPRIDE
>> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
>> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>
>
>
>
> --
> Regards,
> Ashish Mishra
> Graduate Student,
> Computer Science and Automation Department,IISc
> Cell : +91-9611194714
> Mailto : ashishmishra at csa.iisc.ernet.in
>



-- 
Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt


More information about the Soot-list mailing list