Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when building call graph without dependency #591

Closed
Anemone95 opened this issue Dec 4, 2019 · 4 comments
Closed

Exception when building call graph without dependency #591

Anemone95 opened this issue Dec 4, 2019 · 4 comments
Labels

Comments

@Anemone95
Copy link

When I using WALA to build call graph without dependency, I got an exception as follows:

Exception in thread "main" com.ibm.wala.classLoader.NoSuperclassFoundException: No superclass found for <Primordial,Ljava/util/Locale$Cache> Superclass name Lsun/util/locale/LocaleObjectCache
	at com.ibm.wala.classLoader.BytecodeClass.getSuperclass(BytecodeClass.java:281)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder$ConstraintVisitor.processClassInitializer(SSAPropagationCallGraphBuilder.java:1628)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder$ConstraintVisitor.visitNew(SSAPropagationCallGraphBuilder.java:1276)
	at com.ibm.wala.ssa.SSANewInstruction.visit(SSANewInstruction.java:101)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addBlockInstructionConstraints(SSAPropagationCallGraphBuilder.java:272)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addNodeInstructionConstraints(SSAPropagationCallGraphBuilder.java:249)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.unconditionallyAddConstraintsFromNode(SSAPropagationCallGraphBuilder.java:225)
	at com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.addConstraintsFromNode(SSAPropagationCallGraphBuilder.java:190)
	at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.addConstraintsFromNewNodes(PropagationCallGraphBuilder.java:311)
	at com.ibm.wala.ipa.callgraph.propagation.StandardSolver.solve(StandardSolver.java:56)
	at com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder.makeCallGraph(PropagationCallGraphBuilder.java:251)
	at top.anemone.walaDemo.CFGWithoutDependency.main(CFGWithoutDependency.java:90)

To reproduce this issue, clone the demo project from https://github.com/Anemone95/wala-demo at first.

Then using maven to build the analysis code and the target code:

cd wala-demo
mvn clean package

After that, launch top.anemone.walaDemo.CFGWithoutDependency to produce this issue:

$ java -cp wala-code/target/lib/:wala-code/target/wala-code-1.0-SNAPSHOT.jar top.anemone.walaDemo.CFGWithoutDependency
2019-12-04 11:07:03,980 INFO [top.anemone.walaDemo.CFGWithoutDependency] - Create an analysis scope representing the appJar as a J2SE application
2019-12-04 11:07:05,408 INFO [top.anemone.walaDemo.CFGWithoutDependency] - Set entrypoints
2019-12-04 11:07:05,412 INFO [top.anemone.walaDemo.CFGWithoutDependency] - Build the call graph
Exception in thread "main" com.ibm.wala.classLoader.NoSuperclassFoundException: No superclass found for <Primordial,Ljava/util/Locale$Cache> Superclass name Lsun/util/locale/LocaleObjectCache
        ...

So, the analysis code is in https://github.com/Anemone95/wala-demo/blob/master/wala-code/src/main/java/top/anemone/walaDemo/CFGWithoutDependency.java#L49 and the target code is in https://github.com/Anemone95/wala-demo/blob/master/wala-target/src/main/java/top/anemone/walaTarget/NoDependencyDemo.java

I notice a "TODO" comment in com.ibm.wala.classLoader.BytecodeClass#getSuperclass. So, it may be because this phantom handling is not implemented?

Also, when I use ClassHierarchyFactory.make(), the program works fine, which is strange.

@msridhar
Copy link
Member

msridhar commented Dec 4, 2019

The problem is that makeWithPhantom() is currently broken 🙁See #322. makeWithRoot() should work properly; can you try?

I will update the Javadoc around makeWithPhantom() and maybe even remove it.

@Anemone95
Copy link
Author

Yes, I tried makeWithPhantom(), the issue was missing. However, I found that the slices obtained by make are the same as makeWithRoot(), which means when the superclass is not found, make() also finds the subclass. Can you explain the difference with them?

@msridhar
Copy link
Member

msridhar commented Dec 6, 2019

@Anemone95 sorry for the bad documentation here. When using make(), if WALA cannot find the superclass for some class C, it does not include C in the ClassHierarchy. makeWithPhantom() was intended to change this behavior by making C extend a phantom class, but as you noticed, this has not been fully implemented / debugged. makeWithRoot() works by simply treating C as extending the root type in the hierarchy (java.lang.Object) directly. Conceptually this has some disadvantages; e.g., the class observed in the extends clause will not match the supertype in the class hierarchy. But, makeWithRoot() is more robust.

As to why your slices seem to work with both make() and makeWithRoot(), that I'm not sure about. If the subclass is not relevant to the slice, then I guess there would be no difference.

@Anemone95
Copy link
Author

@msridhar Thank you for your answer. Now I know the difference :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants