[Soot-list] Using ThreadLocalObjectAnalysis

Rajendra Kumar Dangwal dangwalrajendra888 at gmail.com
Mon Apr 13 06:18:16 EDT 2020


I tried running the analysis with Soot-2.5.0 and it ran without any
exception.
The later versions of Soot are not supporting the
ThreadLocalObjectsAnalysis and throwing an exception. Reason is, the
DataFlowSummary object is null and being dereferenced at
soot.jimple.toolkits.infoflow.SmartMethodInfoFlowAnalysis.handleInvokeExpr(SmartMethodInfoFlowAnalysis.java:408).
Can someone fix this?

Also, ThreadLocalObjectsAnalysis can only be used with Jimple.
I want to find the thread local objects in Shimple. Is there any other
analysis? If not, where should I make the changes in Soot to support
Shimple?


Thanks,
Rajendra.


On Tue, Apr 7, 2020 at 5:04 PM Eric Bodden <eric.bodden at uni-paderborn.de>
wrote:

> Hi.
>
> This is just a guess but might it be that the project you are analyzing
> contains InvokeDynamic bytecodes? I am pretty sure that the TLO-Analysis is
> too old to be able to handle these. I’d need to be extended.
>
> Cheers
> Eric
>
> > On 6. Apr 2020, at 13:28, Rajendra Kumar Dangwal <
> dangwalrajendra888 at gmail.com> wrote:
> >
> > Hi All,
> >
> > I want to find all the references to the objects which are not escaping
> a thread i.e. Thread local objects. I am using ThreadLocalObjectAnalysis to
> do it. But it is throwing NullPointerException in
> SmartMethodInfoFlowAnalysis. I don't know the reason. I am using Soot
> version 3.0 and Java version 1.7.
> >
> > Code and output are attached for the reference:
> >
> > Soot-Args and addition to pack:
> > -------------------------------------------------------------------
> > String sootArgs[] = {"-cp", classPath, "-pp", "-keep-bytecode-offset",
> "-main-class", "test.Test", "-no-bodies-for-excluded", "-w",
> "-process-dir", dirPath, "-p", "cg", "enabled:true", "-p", "cg.spark",
> "enabled:true",  "-p", "jb", "use-original-names:true", "test.Test"};
> >
> > EscapeAnalysis analysisTransformer = new EscapeAnalysis();
> >
> > PackManager.v().getPack("wjtp").add(new Transform("wjtp.esc",
> analysisTransformer));
> >
> > soot.Main.main(sootArgs);
> > ----------------------------------------------------------------------
> >
> > Analysis:
> >
> > public class EscapeAnalysis extends SceneTransformer {
> >
> >      @Override
> >      protected void internalTransform(String arg0, Map<String, String>
> arg1) {
> >
> >      ThreadLocalObjectsAnalysis tlo = new ThreadLocalObjectsAnalysis(new
> SynchObliviousMhpAnalysis());
> >      tlo.precompute();
> >
> >      Chain<SootClass> classChain = Scene.v().getApplicationClasses();
> >      for(SootClass c : classChain) {
> >           System.out.println("\nClass : " + c + "\n");
> >           List<SootMethod> methodList = c.getMethods();
> >
> >           for(SootMethod m : methodList) {
> >               if(m.isConcrete()) {
> >                    System.out.println("\nMethod : "+ m);
> >                    System.out.print("Thread Local var: ");
> >                    Chain<Local> localVars =
> m.retrieveActiveBody().getLocals();
> >                    for(Local l : localVars) {
> >                     if(tlo.isObjectThreadLocal(l, m))
> >                    System.out.print(l.getName() + " ");
> >                    }
> >                }
> >             }
> >          }
> >      }
> > }
> >
> >
> >
> ----------------------------------------------------------------------------------------
> >
> > Code to be analyzed:
> >
> > package test;
> >
> > class Test{
> >
> >   public static void main(String args[]){
> >     ClassA obj = new ClassA();
> >     MyThread t1 = new MyThread(obj);
> >     MyThread t2 = new MyThread(obj);
> >     t1.start();
> >     t2.start();
> >
> >   }
> > }
> >
> > class MyThread extends Thread{
> >   int localInt;
> >   ClassA obj;
> >   public MyThread(ClassA obj){
> >     localInt = 1;
> >     this.obj = obj;
> >   }
> >
> >   public void run(){
> >     System.out.println("localInt: "+ localInt);
> >     System.out.println("obj.i: "+ obj.i);
> >   }
> > }
> >
> > class ClassA{
> >   public int i = 10;
> > }
> >
> >
> >
> -----------------------------------------------------------------------------------
> >
> > Output:
> >
> > Soot started on Fri Apr 03 12:09:42 IST 2020
> > [Call Graph] For information on where the call graph may be incomplete,
> use the verbose option to the cg phase.
> > [Spark] Pointer Assignment Graph in 0.1 seconds.
> > [Spark] Type masks in 0.0 seconds.
> > [Spark] Pointer Graph simplified in 0.0 seconds.
> > [Spark] Propagation in 0.3 seconds.
> > [Spark] Solution found in 0.3 seconds.
> > [local-objects] Analyzing local objects for test.MyThread
> > [local-objects]   preparing class             Fri Apr 03 12:09:44 IST
> 2020
> > [local-objects]   analyzing class             Fri Apr 03 12:09:44 IST
> 2020
> > java.lang.NullPointerException
> > at
> soot.jimple.toolkits.infoflow.SmartMethodInfoFlowAnalysis.handleInvokeExpr(SmartMethodInfoFlowAnalysis.java:408)
> > at
> soot.jimple.toolkits.infoflow.SmartMethodInfoFlowAnalysis.addFlowToCdfg(SmartMethodInfoFlowAnalysis.java:793)
> > at
> soot.jimple.toolkits.infoflow.SmartMethodInfoFlowAnalysis.generateAbbreviatedInfoFlowGraph(SmartMethodInfoFlowAnalysis.java:151)
> > at
> soot.jimple.toolkits.infoflow.SmartMethodInfoFlowAnalysis.<init>(SmartMethodInfoFlowAnalysis.java:128)
> > at
> soot.jimple.toolkits.infoflow.ClassInfoFlowAnalysis.getMethodInfoFlowSummary(ClassInfoFlowAnalysis.java:91)
> > .....
> >
> > Please help.
> >
> > Thanks,
> > Rajendra
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at CS.McGill.CA
> > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200413/689a6236/attachment.html>


More information about the Soot-list mailing list