Skip to content

A runtime exception bug when SootUp analyzed a class file #802

@kitty-1998

Description

@kitty-1998

I used SootUp v1.1.2 to analyze a class file, but it provided a runtime exception. The minimized example is listed below:

Source code:

class A { public void say(){} }

public class Main {
    public static A a = new A();
    public long run() {
        synchronized(a) {
            try {
                return 1;
            } catch (Throwable t) {
                synchronized (this) {
                    if (a != null) {
                        try {
                            a.say();
                        } catch (Throwable t1) {
                            t.addSuppressed(t1);
                        }
                    }
                }
                throw t;
            }
        }
    }
}

We use the following SootUp APIs for analysis:

classInput = new JavaClassPathAnalysisInputLocation(PATH);
project = JavaProject.builder(language)
        .addInputLocation(classInput)
        .addInputLocation(javaBaseInputLocation)
        .build();
view = project.createView();
for(JavaSootClass sc : view.getClasses()) {
    for(SootMethod sm : sc.getMethods()) {
        outputJimple(sc, true);
        System.out.println(sm.getSignature().toString() + ",jimple end.");
    }
}

and the stack trace:

java.lang.RuntimeException: StmtGraph of <org.apache.lucene.index.IndexWriter: long prepareCommitInternal()> is invalid.
	at sootup.core.model.Body$BodyBuilder.build(Body.java:563)
	at sootup.java.bytecode.frontend.AsmMethodSource.resolveBody(AsmMethodSource.java:264)
	at sootup.core.model.SootMethod.lazyBodyInitializer(SootMethod.java:98)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:183)
	at sootup.core.model.SootMethod.getBody(SootMethod.java:177)
	at sootup.core.util.printer.JimplePrinter.printMethods(JimplePrinter.java:242)
	at sootup.core.util.printer.JimplePrinter.printTo(JimplePrinter.java:210)
	at sootup.core.util.Utils.outputJimple(Utils.java:95)
	at org.sslab.TestMutiFolder.testMulti(TestMutiFolder.java:33)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.IllegalStateException: visualize invalid StmtGraph: <unused url>
	at sootup.core.graph.StmtGraph.validateStmtConnectionsInGraph(StmtGraph.java:242)
	at sootup.core.model.Body$BodyBuilder.build(Body.java:561)
	... 11 more
Caused by: java.lang.IllegalStateException: Stmt '$stack157 := @caughtexception' which is neither the StartingStmt nor a TrapHandler is missing a predecessor!
	at sootup.core.graph.StmtGraph.validateStmtConnectionsInGraph(StmtGraph.java:188)
	... 12 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions