[Soot-list] Issue Loading Method Bodies

95 views
Skip to first unread message

Chris Shiflet

unread,
Sep 7, 2018, 4:03:03 PM9/7/18
to Soot List (soot-list@CS.McGill.CA)
Hi all,

I'm having an issue with loading method bodies when I attempt run the HEROS IFDS solver. Let me start with my stack trace:

Running Heros IFDS Solver...
Exception in thread "main" java.lang.RuntimeException: no active body present for method <com.example.UISample.JSONProject: void main(java.lang.String[])>
at soot.SootMethod.getActiveBody(SootMethod.java:359)
at soot.jimple.toolkits.ide.exampleproblems.IFDSReachingDefinitions.initialSeeds(IFDSReachingDefinitions.java:170)
at heros.solver.IFDSSolver$1.initialSeeds(IFDSSolver.java:68)
at heros.solver.IDESolver.<init>(IDESolver.java:200)
at heros.solver.IDESolver.<init>(IDESolver.java:165)
at heros.solver.IFDSSolver.<init>(IFDSSolver.java:52)
at <redacted calling method in my code>

This is the line where I instantiate IFDSSolver (reacted in the stack trace). You can see it in context later, but I've provided it here for reference:

IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>,
SootMethod, InterproceduralCFG<Unit, SootMethod>> solver =
new IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>>(problem);

I am able to successfully perform the following earlier in the code:
* Build a call-graph using SPARK (shown below), and
* Process active method bodies with BodyTransformer and SceneTransformer in the jtp and wjtp packs, respectively (not shown).

The code leading up to the above error is as follows:

Options.v().setPhaseOption("cg", "safe-newinstance:true");
Options.v().setPhaseOption("cg.cha","enabled:false");

// Enable SPARK
Options.v().setPhaseOption("cg.spark","enabled:true");
Options.v().setPhaseOption("cg.spark","verbose:true");
Options.v().setPhaseOption("cg.spark","on-fly-cg:true");

Options.v().set_allow_phantom_refs(true);
Options.v().set_output_format(Options.output_format_class);

Options.v().set_main_class(mainClass);

SootClass c = Scene.v().loadClass(mainClass, SootClass.BODIES);
c.setApplicationClass();

SootMethod entryPoint = c.getMethodByName("main");
List<SootMethod> entryPoints = new ArrayList<SootMethod>();
entryPoints.add(entryPoint);
Scene.v().setEntryPoints(entryPoints);

Scene.v().loadNecessaryClasses();

// Set output dir
Options.v().set_output_dir(outputDir);

// Execute Soot
soot.Main.main();

// Run Heros IFDS Solver...
JimpleBasedInterproceduralCFG icfg= new JimpleBasedInterproceduralCFG();
System.out.println("1");
IFDSTabulationProblem<Unit, Pair<Value,
Set<DefinitionStmt>>, SootMethod,
InterproceduralCFG<Unit, SootMethod>> problem = new IFDSReachingDefinitions(icfg);

System.out.println("2");
IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>,
SootMethod, InterproceduralCFG<Unit, SootMethod>> solver =
new IFDSSolver<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>>(problem);

System.out.println("Starting solver");
solver.solve();
System.out.println("Done");

Any help is much appreciated!

Best,
---Chris
_______________________________________________
Soot-list mailing list
Soot...@CS.McGill.CA
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list

Eric Bodden

unread,
Sep 11, 2018, 7:37:11 AM9/11/18
to Chris Shiflet, Soot list
Hmm, does the code for this method exist on the classpath you provide to Soot?

com.example.UISample.JSONProject: void main(java.lang.String[])

Cheers
Eric

> On 10. Sep 2018, at 16:55, Chris Shiflet <cshi...@pjrcorp.com> wrote:
>
> Hi Eric,
>
> Yes, I do enabled whole-program mode. I neglected to include them in my code snippet. These lines appears just before the snippet in my previous message.
>
> Options.v().set_whole_program(true);
> Options.v().set_app(true);
>
> Thanks,
> ---Chris
>
> -----Original Message-----
> From: Eric Bodden <eric....@uni-paderborn.de>
> Sent: Monday, September 10, 2018 3:29 AM
> To: Chris Shiflet <cshi...@pjrcorp.com>
> Subject: Re: [Soot-list] Issue Loading Method Bodies
>
> Hi Chris.
>
> Do you have whole-program-mode enabled? (-w flag) I cannot see this in your code.
>
> Cheers
> Eric

Manuel Benz

unread,
Sep 11, 2018, 11:51:14 AM9/11/18
to Eric Bodden, Chris Shiflet, Soot list
Hi Chris.

Can you try the "-no-writeout-body-releasing" option?
Soot releases method bodies on write out by default. Since you are using IFDS after running "soot.Main.main()", write out should already have taken place.

BTW. You do not need to call "Scene.v().loadNecessaryClasses();" manually if you're running Soot by calling "soot.Main.main()" .

Best,
Manuel

Am 11.09.18, 13:37 schrieb "Soot-list im Auftrag von Eric Bodden" <soot-lis...@CS.McGill.CA im Auftrag von eric....@uni-paderborn.de>:

Chris Shiflet

unread,
Sep 11, 2018, 12:37:47 PM9/11/18
to Manuel Benz, Eric Bodden, Soot list
Hi Manuel,

The "-no-writeout-body-releasing" option you suggested corrected my issue. There is an active method body present after setting it to true using the follow line:

Options.v().set_no_writeout_body_releasing(true);

Thanks also for the tip about "Scene.v().loadNecessaryClasses()". Out of curiosity, should I be running Heros elsewhere rather than after executing "soot.Main.main()"?

Thank you for your help!
---Chris

Eric Bodden

unread,
Sep 12, 2018, 2:32:14 AM9/12/18
to Chris Shiflet, Soot list
Hi Chris, hi all.

The recommended way to run _any_ whole-program analysis in Soot, including Heros, is to execute it within the “wjtp” pack. You need to create a new SceneTransformer callback which inside its tranasform-method contains exactly the code you have to execute Heros. This SceneTransformer you then add to the wjtp pack. Then _afterwards_ you call Soot’s main method. That should also take care of the body-release issue, as then Heros will execute before bodies are released.

Best wishes
Eric
Reply all
Reply to author
Forward
0 new messages