soot-oss / soot

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

A self loop edge bug #2063

Open karlls12321 opened 4 months ago

karlls12321 commented 4 months ago

Hi, I used Soot CHA to generate the call graph and found a bug about incorrect loop edges. See the minimized code example below:

public class Main {
    public void foo(){
        String str = this.toString();
    }
    @Override
    public String toString(){
        return "1";
    }
}

When I set the 'Main.toString()' as the entry method, there is a call edge from Main.toString() to Main.toString(), which is incorrect.

Options

Options.v().set_whole_program(true);
Options.v().set_soot_classpath("Path/to/jdk"); 
Options.v().set_no_bodies_for_excluded(true);
Options.v().set_process_dir("Path/to/dir");
Options.v().process_dir();
Options.v().set_allow_phantom_refs(true);
Options.v().setPhaseOption("jb", "use-original-names:true");
Options.v().set_prepend_classpath(false);
Options.v().set_exclude(Constants.excludedClassList);
Scene.v().loadNecessaryClasses();
CHATransformer.v().transform();
PackManager.v().runPacks();
CallGraph cg = Scene.v().getCallGraph();

Version: Soot 4.4.1