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

Crash after upgrading from 3.15.0 to 3.18.0 #4924

Closed
amalloy opened this issue Oct 13, 2021 · 1 comment · Fixed by #4931
Closed

Crash after upgrading from 3.15.0 to 3.18.0 #4924

amalloy opened this issue Oct 13, 2021 · 1 comment · Fixed by #4931
Assignees
Labels

Comments

@amalloy
Copy link

amalloy commented Oct 13, 2021

Commands

checker-framework-3.18.0/checker/bin/javac -processor nullness Issue.java

Inputs

File Issue.java:

interface Callback<T> {}
class Template<T> {
  interface Putter<T> {
    void put(T result);
  }
  class Adapter implements Callback<T> {
    Adapter(Putter<T> putter) {
    }
  }
}

class Super<T> extends Template<T> {}
class Issue extends Super<String> {
  void go(Callback<String> callback) {}
  void foo() {
    go(new Adapter(result -> {}));
  }
}

Outputs

error: AnnotatedTypeMirrors aren't structurally equal.
    type1 = AnnotatedTypeVariable( T extends Object )
    type2 = AnnotatedDeclaredType( String )
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@38e88e13
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: Issue.java
  Last visited tree at line 16 column 5:
      go(new Adapter(result -> {}));
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:22)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.defaultAction(AbstractAtmComboVisitor.java:52)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:56)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:29)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitTypevar_Declared(AbstractAtmComboVisitor.java:543)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:587)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:93)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:105)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:236)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:311)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedMany(DefaultTypeHierarchy.java:541)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:518)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:448)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:45)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:311)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:155)
  	at org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory$KeyForTypeHierarchy.isSubtype(KeyForAnnotatedTypeFactory.java:152)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:131)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2792)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2769)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:3297)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:1680)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:433)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1460)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:106)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:977)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:94)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:559)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:501)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  	at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:82)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:984)
  	at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:542)
  	at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:535)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
  	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:1419)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1376)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
error: AnnotatedTypeMirrors aren't structurally equal.
    type1 = AnnotatedTypeVariable( T extends @Initialized @Nullable Object )
    type2 = AnnotatedDeclaredType( @Initialized @NonNull String )
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@33ce081a
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: Issue.java
  Last visited tree at line 16 column 5:
      go(new Adapter(result -> {}));
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:22)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.defaultAction(AbstractAtmComboVisitor.java:52)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:56)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:29)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitTypevar_Declared(AbstractAtmComboVisitor.java:543)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:587)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:93)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:105)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:236)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:311)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedMany(DefaultTypeHierarchy.java:541)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:518)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:448)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:45)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:311)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:155)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:131)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2792)
  	at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:238)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2769)
  	at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:219)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:3297)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:1680)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethodInvocation(NullnessVisitor.java:528)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethodInvocation(NullnessVisitor.java:68)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1650)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:433)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1460)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:106)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:977)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitMethod(InitializationVisitor.java:334)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethod(NullnessVisitor.java:510)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethod(NullnessVisitor.java:68)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:356)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:94)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:559)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:288)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processClassTree(NullnessVisitor.java:574)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:501)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:190)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  	at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:82)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:984)
  	at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:542)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
  	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:1419)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1376)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
2 errors

Expectation

The nullness checker should not crash on this file. I have verified that this crash does not occur using 3.15.0. I have no deep insights into what specifically might be causing the crash, but I minimized the input as much as I could. In particular, surprisingly, even the empty Super class is necessary: if Issue extends Template<String> directly, the checker succeeds.

mernst added a commit that referenced this issue Oct 13, 2021
@mernst
Copy link
Member

mernst commented Oct 13, 2021

I confirm that the Checker Framework crashes on this code. Thank you for providing a minimized, reproducible bug report -- we appreciate it.

I have committed a test case as checker/tests/nullness/Issue4924.java.

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

Successfully merging a pull request may close this issue.

3 participants