Skip to content

[Bug]: java.lang.OutOfMemoryError for JavaSootClass getMethods() #1382

@leexd210

Description

@leexd210

What happened?

I tried to analyze the LinkDroid for Linkwarden APK v2.1.2 from F-Droid. Extracting the information with the following code:

List<BodyInterceptor> bodyInterceptors = new ArrayList<>();
bodyInterceptors.addAll(DexBodyInterceptors.Default.bodyInterceptors());
bodyInterceptors.addAll(BytecodeBodyInterceptors.Default.getBodyInterceptors());

AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(apk_path, jar_path, bodyInterceptors);
this.view = new JavaView(inputLocation);

This worked, but when i iterated over the classes and found the class androidx.collection.ScatterSet$SetWrapper$iterator$1, getMethods() crashed my program due to a java.lang.OutOfMemoryError. I think there may be an endless loop.

When i manually removed the BodyInterceptor: TypeAssigner, it did not crash.

Version

sootUp 2.0.0

Relevant log output

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.HashMap.newNode(HashMap.java:1909)
        at java.base/java.util.HashMap.putVal(HashMap.java:637)
        at java.base/java.util.HashMap.put(HashMap.java:618)
        at java.base/java.util.HashSet.add(HashSet.java:229)
        at sootup.interceptors.typeresolving.TypeChecker.caseAssignStmt(TypeChecker.java:181)
        at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:229)
        at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:65)
        at sootup.interceptors.typeresolving.TypePromotionVisitor.getPromotedTyping(TypePromotionVisitor.java:47)
        at sootup.interceptors.typeresolving.TypeResolver$$Lambda/0x00007fa0481dd478.apply(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at sootup.interceptors.typeresolving.TypeResolver.resolve(TypeResolver.java:82)
        at sootup.interceptors.TypeAssigner.interceptBody(TypeAssigner.java:42)
        at sootup.apk.frontend.dexpler.DexMethodSource.resolveBody(DexMethodSource.java:87)
        at sootup.apk.frontend.dexpler.DexMethodSource.makeSootMethod(DexMethodSource.java:98)
        at sootup.apk.frontend.main.DexBody.makeSootMethod(DexBody.java:381)
        at sootup.apk.frontend.dexpler.DexMethod.makeSootMethod(DexMethod.java:73)
        at sootup.apk.frontend.dexpler.DexClassSource.loadMethod(DexClassSource.java:158)
        at sootup.apk.frontend.dexpler.DexClassSource.lambda$resolveMethods$0(DexClassSource.java:83)
        at sootup.apk.frontend.dexpler.DexClassSource$$Lambda/0x00007fa04819eb30.apply(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions