Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TypeResolver AssertionError for String methods expecting CharSequence invoked via String literal #975

Open
stschott opened this issue Jul 8, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@stschott
Copy link
Collaborator

stschott commented Jul 8, 2024

What happened?

Since v1.3.0 the TypeResolver throws an AssertionError, when trying to call getBody() on a method like this:

public void method() {
        String someString = "Some String";
        boolean a = someString.contains("abc");
}

The contains method expects a CharSequence as parameter.

Further investigation showed that this only happens for methods expecting a CharSequence parameter, when directly invoked with a String literal.

Version

Latest develop branch

Relevant log output

java.lang.AssertionError
	at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.visit(TypePromotionVisitor.java:68)
	at sootup.java.core.interceptors.typeresolving.TypeChecker.handleInvokeExpr(TypeChecker.java:300)
	at sootup.java.core.interceptors.typeresolving.TypeChecker.caseAssignStmt(TypeChecker.java:220)
	at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:201)
	at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:59)
	at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.getPromotedTyping(TypePromotionVisitor.java:47)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
	at sootup.java.core.interceptors.typeresolving.TypeResolver.resolve(TypeResolver.java:81)
	at sootup.java.core.interceptors.TypeAssigner.interceptBody(TypeAssigner.java:42)
	at sootup.java.bytecode.frontend.AsmMethodSource.resolveBody(AsmMethodSource.java:234)
	at sootup.core.model.SootMethod.lazyBodyInitializer(SootMethod.java:98)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:181)
	at sootup.core.model.SootMethod.getBody(SootMethod.java:177)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at sootup.java.bytecode.SpecialCharacterMethodInvocationTest.test(SpecialCharacterMethodInvocationTest.java:24)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
@stschott stschott added the bug Something isn't working label Jul 8, 2024
@swissiety
Copy link
Collaborator

hint to reproduce: the runtime jar is missing
there are wrong assumptions in the typassigner.. please investigate

@swissiety
Copy link
Collaborator

reason: missing filter for non-locals (i.e. constants) so the assertion cried

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants