siis / coal-strings

Apache License 2.0
0 stars 4 forks source link

Variable not defined before using it as a call base #1

Open ghost opened 2 years ago

ghost commented 2 years ago

Hello,

I'm using COAL on Android applications. Before launching it, I use FlowDroid to get call graph.

On many apps, I encounter the following issue :

java.lang.IndexOutOfBoundsException: Index: 0
        at java.base/java.util.Collections$EmptyList.get(Collections.java:4483)
        at edu.psu.cse.siis.coal.arguments.MySmartLocalDefs.<init>(ConstraintCollector.java:247)
        at edu.psu.cse.siis.coal.arguments.CCVisitor.<init>(ConstraintCollector.java:319)
        at edu.psu.cse.siis.coal.arguments.ConstraintCollector.handleMethod(ConstraintCollector.java:132)
        at edu.psu.cse.siis.coal.arguments.ConstraintCollector.globalCollection(ConstraintCollector.java:172)
        at edu.psu.cse.siis.coal.arguments.StringValueAnalysis.initialize(StringValueAnalysis.java:50)
        at edu.psu.cse.siis.coal.PropagationSceneTransformer.internalTransform(PropagationSceneTransformer.java:63)
        at soot.SceneTransformer.transform(SceneTransformer.java:36)
        at soot.Transform.apply(Transform.java:105)
        at soot.ScenePack.internalApply(ScenePack.java:37)
        at soot.Pack.apply(Pack.java:118)

Here is a snippet to reproduce it :

public class Test1 extends Activity {
    public void printString(String s) {
        StringBuilder sb = new StringBuilder();
        sb.append(s);
        sb = new StringBuilder().append(sb).append(s);
        System.out.print(sb.toString());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        printString("abc");
    }
}

Best,

Séverine

JordanSamhi commented 2 years ago

Hi @DSeverine,

Do you still have the problem? I just tested with your code snippet and could not reproduce the error.

Let me know,

ghost commented 2 years ago

I still have this problem.

If you don't have this problem, that may be due to two reasons.

First, I'm initializing Soot myself before using FlowDroid and COAL. I have probably missed an option.

Options.v().set_allow_phantom_refs(true);
Options.v().set_prepend_classpath(true);
Options.v().set_process_multiple_dex(true);
Options.v().set_search_dex_in_archives(true);
Options.v().set_whole_program(true);
Options.v().set_android_jars(androidDir);
Options.v().set_output_format(Options.output_format_jimple);
Options.v().set_process_dir(Collections.singletonList(apk));
Options.v().set_src_prec(Options.src_prec_apk);
Options.v().set_no_writeout_body_releasing(true);

Second, I have made a few modifications to COAL to update Soot version to 4.3.0.

Thanks a lot for your anwser,

Séverine