[Soot-list] Using ThreadLocalObjectAnalysis

Eric Bodden eric.bodden at uni-paderborn.de
Tue Apr 7 07:34:50 EDT 2020


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



More information about the Soot-list mailing list