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

3.22.1 crashes when an enum passes 0 arguments to its vararg constructor #5189

Closed
amalloy opened this issue Jun 30, 2022 · 1 comment · Fixed by #5197
Closed

3.22.1 crashes when an enum passes 0 arguments to its vararg constructor #5189

amalloy opened this issue Jun 30, 2022 · 1 comment · Fixed by #5197
Labels

Comments

@amalloy
Copy link

amalloy commented Jun 30, 2022

Commands

./checker-framework-3.22.1/checker/bin/javac -processor nullness CFRepro.java

Inputs

CFRepro.java:

enum CFRepro {
  EMPTY() {};

  CFRepro(String... args) {
  }
}

Output

$ ./checker-framework-3.22.1/checker/bin/javac -processor nullness CFRepro.java error: SourceChecker.typeProcess: unexpected Throwable (IndexOutOfBoundsException) while processing CFRepro.java; message: Index -1 out of bounds for length 0
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: CFRepro.java
  Last visited tree at line 2 column 8:
    EMPTY() {};
  Exception: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0; java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
  	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
  	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
  	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
  	at java.base/java.util.Objects.checkIndex(Objects.java:372)
  	at java.base/java.util.ArrayList$SubList.get(ArrayList.java:1180)
  	at java.base/java.util.Collections$UnmodifiableList.get(Collections.java:1314)
  	at org.checkerframework.framework.util.AnnotatedTypes.adaptParameters(AnnotatedTypes.java:991)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitNewClass(BaseTypeVisitor.java:1936)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitNewClass(BaseTypeVisitor.java:180)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1727)
  	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:349)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:180)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitVariable(TreeScanner.java:223)
  	at org.checkerframework.framework.source.SourceVisitor.visitVariable(SourceVisitor.java:100)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1446)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:180)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:990)
  	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:349)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:180)
  	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:539)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:485)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:180)
  	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:991)
  	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: SourceChecker.typeProcess: unexpected Throwable (IndexOutOfBoundsException) while processing CFRepro.java; message: Index -1 out of bounds for length 0
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: CFRepro.java
  Last visited tree at line 2 column 8:
    EMPTY() {};
  Exception: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0; java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
  	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
  	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
  	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
  	at java.base/java.util.Objects.checkIndex(Objects.java:372)
  	at java.base/java.util.ArrayList$SubList.get(ArrayList.java:1180)
  	at java.base/java.util.Collections$UnmodifiableList.get(Collections.java:1314)
  	at org.checkerframework.framework.util.AnnotatedTypes.adaptParameters(AnnotatedTypes.java:991)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitNewClass(BaseTypeVisitor.java:1936)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitNewClass(NullnessVisitor.java:729)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitNewClass(NullnessVisitor.java:68)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1727)
  	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:349)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:180)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitVariable(TreeScanner.java:223)
  	at org.checkerframework.framework.source.SourceVisitor.visitVariable(SourceVisitor.java:100)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1446)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:155)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:51)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:990)
  	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:349)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:180)
  	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:539)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:288)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processClassTree(NullnessVisitor.java:575)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:485)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:180)
  	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:991)
  	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

No crash. This is perfectly valid Java.

Notes

I have confirmed that this does not crash in 3.18.0. I have not checked any versions in between.

@mernst mernst linked a pull request Jul 9, 2022 that will close this issue
@mernst mernst added the crash label Jul 9, 2022
@mernst
Copy link
Member

mernst commented Jul 9, 2022

Thanks for the report, and our apologies for the crash.

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