soot-oss / soot

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

Failed to apply jb #262

Open algobardo opened 9 years ago

algobardo commented 9 years ago

Trying to load class file and write it back (in my setting the entire android framework is processed, but maybe you are able to reproduce with the framework in the classpath)

Exception in thread "main" java.lang.RuntimeException: Failed to apply jb to android.util.MathUtils: float max(int,int,int)

at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1677)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:91)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:324)
at soot.jimple.toolkits.annotation.LineNumberAdder.internalTransform(LineNumberAdder.java:44)
at soot.PackManager.runPacksNormally(PackManager.java:449)
at soot.PackManager.runPacks(PackManager.java:391)
at entry$.sootFrameworkInstrumentClasses(entry.scala:166)
at entry$.main(entry.scala:272)
at entry.main(entry.scala)

Caused by: Unexpected type null

at soot.jimple.toolkits.typing.integer.ClassHierarchy.typeNode(ClassHierarchy.java:178)
at soot.jimple.toolkits.typing.integer.TypeResolver.typeVariable(TypeResolver.java:109)

at 
soot.jimple.toolkits.typing.integer.ConstraintCollector.caseReturnStmt(ConstraintCollector.java:1016)
    at soot.jimple.internal.JReturnStmt.apply(JReturnStmt.java:70)
    at soot.jimple.toolkits.typing.integer.ConstraintCollector.collect(ConstraintCollector.java:114)
    at soot.jimple.toolkits.typing.integer.TypeResolver.collect_constraints_1(TypeResolver.java:227)
    at soot.jimple.toolkits.typing.integer.TypeResolver.resolve_step_1(TypeResolver.java:180)
    at soot.jimple.toolkits.typing.integer.TypeResolver.resolve(TypeResolver.java:140)
    at soot.jimple.toolkits.typing.fast.TypeResolver.inferTypes(TypeResolver.java:183)
    at soot.jimple.toolkits.typing.TypeAssigner.internalTransform(TypeAssigner.java:101)
    at soot.BodyTransformer.transform(BodyTransformer.java:51)
    at soot.Transform.apply(Transform.java:105)
    at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:66)
    at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:89)
    at soot.Pack.apply(Pack.java:126)
    at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:1675)
    ... 8 more
ericbodden commented 9 years ago

Can you please extract the android.util.MathUtils.class file and give it to us? I don't seem to be able to find it in any of my android.jar files. Thanks

algobardo commented 9 years ago

I was unable to reproduce without the framework classes...because i get another exception that i did not understand. Please use the original repository. If you are short on space, the android-platform folder is not needed, without that the size is approx 50Mb: 20 Mb soots, 10Mb classpath, 20Mb the framework classes,

ericbodden commented 9 years ago

Space is not the issue but bandwith is. I only know how to clone the repo entirely, and that takes hours. So please remove everything that's not needed and put that into a fresh repo.

Thanks, Eric

On 17.09.2014, at 14:04, algobardo notifications@github.com wrote:

I was unable to reproduce without the framework classes...because i get another exception that i did not understand. Please use the original repository. If you are short on space, the android-platform folder is not needed, without that the size is approx 50Mb, 20 Mb soots, 10Mb classpath, 20Mb the framework classes,

— Reply to this email directly or view it on GitHub.

algobardo commented 9 years ago

Yes, I understand, thanks. I will try again this night, my last trial is in https://github.com/algobardo/smallerSootReproduce if you move the util folder inside ./res/android then, when you type gradle run, you should also instrument the MathUtils class. Right now i'm getting an error saying that class names do not match...which is weird because i don't get that when i also have all the other framework classes. Let's hope to reproduce the problem above this night. Thanks again.

ericbodden commented 9 years ago

I think I can reproduce things now, thanks.

Eric

On 18.09.2014, at 15:46, algobardo notifications@github.com wrote:

Yes, I understand, thanks. I will try again this night, my last trial is in https://github.com/algobardo/smallerSootReproduce if you move the util folder inside ./res/android then, when you type gradle run, you should also instrument the MathUtils class. Right now i'm getting an error saying that class names do not match...which is weird because i don't get that when i also have all the other framework classes. Let's hope to reproduce the problem above this night. Thanks again.

— Reply to this email directly or view it on GitHub.

algobardo commented 9 years ago

I think it would be nice to insert into the soot tests task this dx stuff... don't you ? it spots bug easily.

ericbodden commented 9 years ago

@algobardo Yes that's a good idea. We should to this. But to do so we need to know which command line you are using to invoke Soot. We don't want to rely on gradle or any other build tools.

ericbodden commented 9 years ago

Assigning this to @Alexandre-Bartel as it looks like a typing issue.

Alexandre-Bartel commented 9 years ago

@algobardo I cannot reproduce this bug. What I did is (1) download the algobardo/smallerSootReproduce repository (2) copy ./util/ to ./res/classes/android/ (3) run gradle. Anything else I should do?