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

Nullness checker crash: StructuralEqualityComparer: unexpected combination #6770

Closed
Calvin-L opened this issue Aug 27, 2024 · 0 comments · Fixed by #6809
Closed

Nullness checker crash: StructuralEqualityComparer: unexpected combination #6770

Calvin-L opened this issue Aug 27, 2024 · 0 comments · Fixed by #6809
Assignees
Labels

Comments

@Calvin-L
Copy link
Contributor

Checker Framework 3.46.0 (latest release).

[ERROR] error: StructuralEqualityComparer: unexpected combination:  type: [TYPEVAR class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable] T extends Object  supertype: [DECLARED class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType] BiPredicate<REDACTED, String>
[ERROR] @Initialized @NonNull BiPredicate<@Initialized @NonNull REDACTED, @Initialized @NonNull String>
[ERROR]     visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@46d9c0b4
[ERROR]   ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.46.0. 
[ERROR]   Compilation unit: [REDACTED]
[ERROR]   Last visited tree at line 23 column 5:
[ERROR]       private final Supplier<BiPredicate<REDACTED, String>> supplier = Suppliers.memoize(() -> this:accept);
[ERROR]   Exception: java.lang.Throwable; java.lang.Throwable
[ERROR]     at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:26)
[ERROR]     at org.checkerframework.framework.type.visitor.AtmComboVisitor.defaultAction(AtmComboVisitor.java:66)
[ERROR]     at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:49)
[ERROR]     at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:30)
[ERROR]     at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitTypevar_Declared(AbstractAtmComboVisitor.java:512)
[ERROR]     at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:589)
[ERROR]     at org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:84)
[ERROR]     at org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:94)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:339)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:415)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedMany(DefaultTypeHierarchy.java:645)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:609)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:542)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:49)
[ERROR]     at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:313)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:259)
[ERROR]     at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:137)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3139)
[ERROR]     at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:250)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3114)
[ERROR]     at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:231)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3033)
[ERROR]     at org.checkerframework.checker.initialization.InitializationVisitor.commonAssignmentCheck(InitializationVisitor.java:136)
[ERROR]     at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:179)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1617)
[ERROR]     at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:158)
[ERROR]     at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:51)
[ERROR]     at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1045)
[ERROR]     at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
[ERROR]     at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
[ERROR]     at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
[ERROR]     at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
[ERROR]     at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
[ERROR]     at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
[ERROR]     at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:98)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:612)
[ERROR]     at org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:246)
[ERROR]     at org.checkerframework.checker.nullness.NullnessVisitor.processClassTree(NullnessVisitor.java:601)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:558)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:189)
[ERROR]     at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:860)
[ERROR]     at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
[ERROR]     at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:86)
[ERROR]     at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1094)
[ERROR]     at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:559)
[ERROR]     at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
[ERROR]     at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:854)
[ERROR]     at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1397)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1354)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1495)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1411)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
[ERROR]     at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
[ERROR]     at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
[ERROR]     at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

I was not able to make a minimized version that exhibits the bug. Here is roughly what the code looks like:

import java.util.function.BiPredicate;
import java.util.function.Supplier;

class Suppliers {
    public static <T> Supplier<T> memoize(Supplier<T> delegate) {
        return delegate;
    }
}

public abstract class Crash_3_46_0_BiPredicate {

    private final Supplier<BiPredicate<Integer, String>> supplier = Suppliers.memoize(() -> this::accept);

    protected abstract boolean accept(Integer scope, String name);

}

But this minimal example reports something different (and equally cryptic):

Compilation failure
error: AsSuperVisitor: type is not an erased subtype of supertype.

In both projects I can fix the crash by manually specifying the <T> parameter to Suppliers.memoize:

Suppliers.<BiPredicate<Integer, String>>memoize(() -> this::accept)

Fixing the crash reveals a true initialization error.

Possibly related to #6755 or #6671.

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.

2 participants