soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.89k stars 708 forks source link

Java JDK class analysis attempts to resolve Android specific class resulting in RuntimeException #1499

Closed knewbury01 closed 3 years ago

knewbury01 commented 3 years ago

Im not entirely sure this is an error, but to me the behaviour is unexpected.

Replication details:

Failure stack trace:

Found 55 instanceinvoke , 4 staticinvoke edge descriptions
java.lang.RuntimeException: This operation requires resolving level HIERARCHY but android.os.Handler is at resolving level DANGLING
If you are extending Soot, try to add the following call before calling soot.Main.main(..):
Scene.v().addBasicClass(android.os.Handler,HIERARCHY);
Otherwise, try whole-program mode (-w).
    at soot.SootClass.checkLevelIgnoreResolving(SootClass.java:198)
    at soot.SootClass.checkLevel(SootClass.java:180)
    at soot.FastHierarchy.canStoreClass(FastHierarchy.java:358)
    at soot.FastHierarchy.canStoreType(FastHierarchy.java:307)
    at soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder.skipSite(OnFlyCallGraphBuilder.java:676)
    at soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder.addType(OnFlyCallGraphBuilder.java:594)
    at soot.jimple.toolkits.callgraph.CallGraphBuilder.processReceivers(CallGraphBuilder.java:211)
    at soot.jimple.toolkits.callgraph.CallGraphBuilder.process(CallGraphBuilder.java:131)
    at soot.jimple.toolkits.callgraph.CallGraphBuilder.build(CallGraphBuilder.java:117)
    at soot.jimple.toolkits.callgraph.CHATransformer.internalTransform(CHATransformer.java:51)
    at soot.SceneTransformer.transform(SceneTransformer.java:36)
    at soot.Transform.apply(Transform.java:102)
    at soot.RadioScenePack.internalApply(RadioScenePack.java:68)
    at soot.jimple.toolkits.callgraph.CallGraphPack.internalApply(CallGraphPack.java:58)
    at soot.Pack.apply(Pack.java:117)
    at soot.PackManager.runWholeProgramPacks(PackManager.java:611)
    at soot.PackManager.runPacksNormally(PackManager.java:495)
    at soot.PackManager.runPacks(PackManager.java:419)
    at soot.Main.run(Main.java:291)
    at soot.Main.main(Main.java:140

Bug details:

Reasons why I think this is a bug:

What I am unsure about:

linghuiluo commented 3 years ago

Your cg option doesn’t look right for me

linghuiluo commented 3 years ago

You can ignore the resolution error with -ignore-resolving-Levels

knewbury01 commented 3 years ago

The error still occurs even with the cg option omitted (I admit its a bit weird, but its for a bit of an odd use case).

But ! The -ignore-resolving-levels option definitely allows Soot to complete its run, thanks! I was not aware of that option, I only tried -ire previously. Thanks!