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

Regression in 3.7.1: InternalUtils.symbol: tree is null #3850

Closed
vlsi opened this issue Nov 3, 2020 · 4 comments · Fixed by #3864
Closed

Regression in 3.7.1: InternalUtils.symbol: tree is null #3850

vlsi opened this issue Nov 3, 2020 · 4 comments · Fixed by #3864
Assignees
Labels
Milestone

Comments

@vlsi
Copy link
Contributor

vlsi commented Nov 3, 2020

Code: https://github.com/vlsi/calcite/blob/78d97778f938ab435851487f2e91fcfd1d293914/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java#L41

The error is not present in 3.7.0

Error:

error: InternalUtils.symbol: tree is null
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: .../calcite/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
  Last visited tree at line 41 column 1:
  public class SqlParserPos implements Serializable {
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:16)
  	at org.checkerframework.javacutil.TreeUtils.elementFromTree(TreeUtils.java:459)
  	at org.checkerframework.javacutil.TreeUtils.elementFromDeclaration(TreeUtils.java:517)
  	at org.checkerframework.checker.nullness.NullnessTransfer.strengthenAnnotationOfEqualTo(NullnessTransfer.java:206)
  	at org.checkerframework.checker.nullness.NullnessTransfer.strengthenAnnotationOfEqualTo(NullnessTransfer.java:62)
  	at org.checkerframework.framework.flow.CFAbstractTransfer.visitEqualTo(CFAbstractTransfer.java:744)
  	at org.checkerframework.framework.flow.CFAbstractTransfer.visitEqualTo(CFAbstractTransfer.java:94)
  	at org.checkerframework.dataflow.cfg.node.EqualToNode.accept(EqualToNode.java:31)
  	at org.checkerframework.dataflow.analysis.AbstractAnalysis.callTransferFunction(AbstractAnalysis.java:338)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.callTransferFunction(ForwardAnalysisImpl.java:390)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysisBlock(ForwardAnalysisImpl.java:130)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysis(ForwardAnalysisImpl.java:107)
  	at org.checkerframework.framework.flow.CFAbstractAnalysis.performAnalysis(CFAbstractAnalysis.java:109)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.analyze(GenericAnnotatedTypeFactory.java:1341)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1267)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:1686)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:343)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:322)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:175)
  	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:916)
  	at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:503)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:190)
  	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:1418)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
@vlsi
Copy link
Contributor Author

vlsi commented Nov 3, 2020

The offending call seems to be added in 1a0712f#diff-8382353728edc77ba9bf0342019ad97ce6be2f99a0b00492f97b423acf7f18e9R207

analysis.getContainingMethod(secondNode.getTree()) returns null, it passes that to TreeUtils.elementFromDeclaration which fails with BugInCF

@vlsi
Copy link
Contributor Author

vlsi commented Nov 3, 2020

The only @PolyNull usage in SqlParserPos is

  private static Iterable<@PolyNull SqlParserPos> toPos(
      Iterable<? extends @PolyNull SqlNode> nodes) {
    return Util.transform(nodes,
        node -> node == null ? castNonNull(null) : node.getParserPosition());
  }

and Util.transform is

  public static <F, T> Iterable<T> transform(Iterable<? extends F> iterable,
      java.util.function.Function<? super F, ? extends T> function) {
    // FluentIterable provides toString
    return new FluentIterable<T>() {
      @Override public Iterator<T> iterator() {
        return Util.transform(iterable.iterator(), function);
      }
    };
  }

@smillst smillst added the crash label Nov 5, 2020
@smillst smillst added this to the Critical milestone Nov 5, 2020
mernst added a commit to mernst/checker-framework that referenced this issue Nov 5, 2020
mernst added a commit to mernst/checker-framework that referenced this issue Nov 5, 2020
mernst added a commit to mernst/checker-framework that referenced this issue Nov 5, 2020
@mernst
Copy link
Member

mernst commented Nov 5, 2020

Thanks for the useful bug report. (And, my apologies for the bug; I didn't have a test case that used a lambda.)

I have opened a pull request that fixes the crash.

@vlsi
Copy link
Contributor Author

vlsi commented Nov 5, 2020

No worries. I just hoped update to 3.7.1 to auto fix a half of the remaining 350+ issues :)
Well, the magic did not happen.

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