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

Not an type argument crashes #792

Open
Ao-senXiong opened this issue Jun 24, 2024 · 3 comments
Open

Not an type argument crashes #792

Ao-senXiong opened this issue Jun 24, 2024 · 3 comments
Assignees
Labels

Comments

@Ao-senXiong
Copy link
Member

Ao-senXiong commented Jun 24, 2024

Found this crash when I look into type check guava using PICO.

Command:

./checker/bin/javac -cp "framework/build/libs/framework-3.42.0-eisop4-SNAPSHOT.jar:framework/build/classes/java/main:framework/build/classes/java/test:javacutil/libs/javacutil-3.42.0-eisop4-SANPSHOT.jar:javacutil/build/classes/java/main:javacutil/build/classes/java/test" -processorpath "framework/build/classes/java/test" -processor viewpointtest.ViewpointTestChecker Test.java

File:

public class Test<V extends Object> {
    Object obj = ((Inner) null).future;

    class Inner<V extends Object> {
        final Inner<? extends V> future = null;
    }
}

Stacktrace:

error: Wildcard /*INFERENCE FAILED for:*/ ? extends @Top Object is not a type argument of @Top Inner</*RAW*/>
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0-eisop4-SNAPSHOT, branch master, 2024-06-05, commit 481040f, dirty=true. 
  Checker: class viewpointtest.ViewpointTestChecker
  Visitor: class org.checkerframework.common.basetype.BaseTypeVisitor
  Compilation unit: Test.java
  Last visited tree at line 1 column 1:
  public class Test<V extends Object> {
  Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:34)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.getTypeParameterElement(PropagationTypeAnnotator.java:227)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitWildcard(PropagationTypeAnnotator.java:133)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitWildcard(PropagationTypeAnnotator.java:36)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.accept(AnnotatedTypeMirror.java:2322)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:207)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.scan(PropagationTypeAnnotator.java:75)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitWildcard(PropagationTypeAnnotator.java:159)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitWildcard(PropagationTypeAnnotator.java:36)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.accept(AnnotatedTypeMirror.java:2322)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:207)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.scan(PropagationTypeAnnotator.java:75)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.scan(PropagationTypeAnnotator.java:36)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:224)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scanAndReduce(AnnotatedTypeScanner.java:231)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visitDeclared(AnnotatedTypeScanner.java:277)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitDeclared(PropagationTypeAnnotator.java:113)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.visitDeclared(PropagationTypeAnnotator.java:36)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1058)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:207)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.scan(PropagationTypeAnnotator.java:75)
        at org.checkerframework.framework.type.typeannotator.PropagationTypeAnnotator.scan(PropagationTypeAnnotator.java:36)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:195)
        at org.checkerframework.framework.type.typeannotator.ListTypeAnnotator.scan(ListTypeAnnotator.java:58)
        at org.checkerframework.framework.type.typeannotator.ListTypeAnnotator.scan(ListTypeAnnotator.java:20)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:195)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.addComputedTypeAnnotations(GenericAnnotatedTypeFactory.java:2059)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.addComputedTypeAnnotations(GenericAnnotatedTypeFactory.java:1992)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.getAnnotatedType(AnnotatedTypeFactory.java:1502)
        at org.checkerframework.framework.flow.CFAbstractTransfer.getValueFromFactory(CFAbstractTransfer.java:215)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitFieldAccess(CFAbstractTransfer.java:643)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitFieldAccess(CFAbstractTransfer.java:97)
        at org.checkerframework.dataflow.cfg.node.FieldAccessNode.accept(FieldAccessNode.java:92)
        at org.checkerframework.dataflow.analysis.AbstractAnalysis.callTransferFunction(AbstractAnalysis.java:356)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.callTransferFunction(ForwardAnalysisImpl.java:393)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysisBlock(ForwardAnalysisImpl.java:157)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysis(ForwardAnalysisImpl.java:110)
        at org.checkerframework.framework.flow.CFAbstractAnalysis.performAnalysis(CFAbstractAnalysis.java:150)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.analyze(GenericAnnotatedTypeFactory.java:1624)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1469)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:2101)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:435)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:591)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:195)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:860)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
        at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:89)
        at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1136)
        at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:556)
        at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:193)
        at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:854)
        at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1397)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1354)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
1 error

@Ao-senXiong
Copy link
Member Author

Remove the usage of raw type will fix the problem.

public class Test<V extends Object> {
    Object obj = ((Inner<V>) null).future;

    class Inner<V extends Object> {
        final Inner<? extends V> future = null;
    }
}

@Ao-senXiong Ao-senXiong self-assigned this Jun 25, 2024
@Ao-senXiong
Copy link
Member Author

This happens in running PICO against guava a lot. And the question is how to handle raw type in here:
image
image
image
By design, the type argument for raw type is uninferred wildcards. However, it say type argument for @Top Test</*RAW*/>.@Top Inner</*RAW*/> is ? extends /*INFERENCE FAILED for:*/? extends @Top Object

@Ao-senXiong
Copy link
Member Author

This example also crashes.

public class Test<V extends Object> {
    Test<? extends V> nullObj = null;
    Object obj = ((Test) null).nullObj;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant