[Soot-list] bug in Scene.getSootClass()?

Tony Yan yan at cse.ohio-state.edu
Fri Apr 26 22:21:05 EDT 2013


Hi,

A test case is attached at the very end. Feel free to fix it whenever
you are sure.

Thanks,
Tony

---

import java.util.Map;

import soot.Body;
import soot.BodyTransformer;
import soot.PackManager;
import soot.Transform;

public class Main {
  public static void main(String[] args) {
    String[] sootArgs = {
      "-allow-phantom-refs",
      "-f", "n",
      "-cp", WhateverJarsYouNeed,
      "-process-dir", "./bin",
    };
    PackManager.v().getPack("jtp").add(new Transform("jtp.Main", new
BodyTransformer() {

      protected void internalTransform(Body b, String s, Map m) {
        boolean act =
soot.Scene.v().getSootClass("ImpossibleToExistClass").isPhantom();
        System.out.println("Expected: true, Actual: " + act);
        System.exit(0);
      }
    }));

    soot.Main.main(sootArgs);
  }
}

On Fri, Apr 26, 2013 at 9:18 PM, Marc-André Laverdière-Papineau
<marc-andre.laverdiere-papineau at polymtl.ca> wrote:
> Hello Tony,
>
> I looked at the execution path and I can confirm what you reported.
>
> Do you have a test that shows the issue? It would be nice to start
> having some kind regression testing :)
>
> If you wish, you could write the patch and/or put the issue on Github.
> That would leave the credit to you.
>
> Otherwise, I can make a pull request for that tomorrow.
>
> Marc-André Laverdière-Papineau
> Doctorant - PhD Candidate
>
> On 04/26/2013 01:17 PM, Tony Yan wrote:
>> Hi,
>>
>> There's likely to be a bug in Scene.getSootClass() on handling of
>> phantom classes:
>>
>>    if (allowsPhantomRefs() ||
>>                                  className.equals(SootClass.INVOKEDYNAMIC_DUMMY_CLASS_NAME)) {
>>       SootClass c = new SootClass(className);
>>       c.setPhantom(true);
>>       addClass(c);
>>       return c;
>>    }
>>
>> addClass(c) would contains a call c.setLibraryClass() which does
>> c.setPhantom(false). Thus, the returned class is falsely flagged as
>> non-phantom. A fix is to re-order the two calls:
>>       addClass(c);
>>       c.setPhantom(true);
>>
>> Thanks,
>> Tony
>>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


More information about the Soot-list mailing list