eisop / checker-framework

Pluggable type-checking for Java
https://eisop.github.io/
Other
19 stars 18 forks source link

Different behavior when using `-AatfDoNotCache` for varargs method #828

Open Ao-senXiong opened 3 months ago

Ao-senXiong commented 3 months ago

Code

public class VarargsMethod {
    public boolean varargsMethod(Object... args) {
        return false;
    }

    static class Subclass extends VarargsMethod {
        @Override
        public boolean varargsMethod(Object... args) {
            return super.varargsMethod(new Object[2]);
        }
    }
}

Command1:

./checker/bin/javac -cp "framework/build/classes/java/main:framework/build/classes/java/test" -processorpath "checker/dist/checker.jar:framework/build/classes/java/test" -processor viewpointtest.ViewpointTestChecker -AatfDoNotCache VarargsMethod.java

Result 1

error: Set vararg type before resetting parameter types
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0-eisop5-SNAPSHOT, branch master, 2024-08-01, commit 7f6c29e, dirty=true. 
  Checker: class viewpointtest.ViewpointTestChecker
  Visitor: class org.checkerframework.common.basetype.BaseTypeVisitor
  Compilation unit: VarargsMethod.java
  Last visited tree at line 1 column 1:
  public class VarargsMethod {
  Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:22)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedExecutableType.setParameterTypes(AnnotatedTypeMirror.java:1295)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.viewpointAdaptMethod(AbstractViewpointAdapter.java:189)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2566)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2508)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.methodFromUse(GenericAnnotatedTypeFactory.java:2333)
        at org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator.visitNewArray(PropagationTreeAnnotator.java:141)
        at org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator.visitNewArray(PropagationTreeAnnotator.java:48)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewArray.accept(JCTree.java:1777)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
        at org.checkerframework.framework.type.treeannotator.ListTreeAnnotator.defaultAction(ListTreeAnnotator.java:54)
        at org.checkerframework.framework.type.treeannotator.ListTreeAnnotator.defaultAction(ListTreeAnnotator.java:22)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visitNewArray(SimpleTreeVisitor.java:443)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewArray.accept(JCTree.java:1777)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.addComputedTypeAnnotations(GenericAnnotatedTypeFactory.java:2084)
        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.visitNode(CFAbstractTransfer.java:562)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitNode(CFAbstractTransfer.java:97)
        at org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor.visitArrayCreation(AbstractNodeVisitor.java:347)
        at org.checkerframework.dataflow.cfg.node.ArrayCreationNode.accept(ArrayCreationNode.java:73)
        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:1634)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1523)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:2135)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:445)
        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:808)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
        at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:89)
        at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1135)
        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: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:1417)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
        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)
1 error

Command2:

./checker/bin/javac -cp "framework/build/classes/java/main:framework/build/classes/java/test" -processorpath "checker/dist/checker.jar:framework/build/classes/java/test" -processor viewpointtest.ViewpointTestChecker VarargsMethod.java  

Result2:

no error
Ao-senXiong commented 3 months ago

This is definitely a bug, but PICO get the crash with PICONoinitVisitor with or without the compiler option.

Ao-senXiong commented 3 months ago

However, I just checked typetool#1809, I also notice the crash stopped happening after removing unrelated methods for PICO.