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

An inconsistency between call graphs #903

Closed
karlls12321 opened this issue Apr 3, 2024 · 2 comments · Fixed by #936
Closed

An inconsistency between call graphs #903

karlls12321 opened this issue Apr 3, 2024 · 2 comments · Fixed by #936
Assignees

Comments

@karlls12321
Copy link

karlls12321 commented Apr 3, 2024

I used SootUp to construct call graphs for my project, and found a bug in CHA algorithms.

A.java

package org.sslab;
import java.io.Closeable;
public interface A extends Closeable {
    @Override
    default void close(){
        close();
    }
}

B.java

package org.sslab;
public class B implements A {
    public static void main(String[] args) {
        try (B b = new B()) {
        }
    }
}

In the above code examples, RTA call graph includes an edge from B.main to A.close that is reasonable, but CHA does not have. I think CHA should provide a more sound analysis results.

This edge seems related to callback process of SootUp as no type hierarchy and new expressions here to guide the above two algorithms.

SootUp version: 1.1.2

Configuration

AnalysisInputLocation<JavaSootClass> javaBaseInputLocation = new JavaClassPathAnalysisInputLocation("Path/to/javaBase", SourceType.Library);
AnalysisInputLocation<JavaSootClass> classInput = new JavaClassPathAnalysisInputLocation("Path/to/classDir", SourceType.Application);
JavaProject project = JavaProject.builder(new JavaLanguage(8))
          .addInputLocation(classInput)
          .addInputLocation(javaBaseInputLocation)
          .build();
JavaView view = project.createView();

String EntrySignature="<org.sslab.B: void main(java.lang.String[])>"
List<MethodSignature> entryMethods = new ArrayList<>();
for (JavaSootClass klass : classes) {
    for (JavaSootMethod method : klass.getMethods()) {
        if (method.isMain() && method.getSignature().toString().equals(EntrySignature)) {
            entryMethods.add(method.getSignature());
        }
    }
}

CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(Constants.view);
CallGraph cg1 = cha.initialize(entryMethods);

CallGraphAlgorithm rta = new RapidTypeAnalysisAlgorithm(view);
CallGraph cg2 = rta.initialize(entryMethods);
@JonasKlauke
Copy link
Collaborator

It is really weird that RTA has an edge and CHA does not have an edge, since RTA works like CHA but filters the results, so everything RTA finds should be in CHA. I will investigate why there is no edge in CHA

@JonasKlauke
Copy link
Collaborator

JonasKlauke commented May 27, 2024

added bugfix in PR #936
Could not be reproduced or is already fixed

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