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

Assignment context and caching #2847

Closed
wmdietl opened this issue Oct 31, 2019 · 3 comments
Closed

Assignment context and caching #2847

wmdietl opened this issue Oct 31, 2019 · 3 comments
Assignees
Milestone

Comments

@wmdietl
Copy link
Member

wmdietl commented Oct 31, 2019

@smillst Using assignment context seems to have a problem with caching. If the caching is only disabled in dataflow, the nullness checker will crush when checking https://github.com/typetools/checker-framework/blob/master/framework/tests/all-systems/Issue2302.java.
When visiting the return part in InitializationAnnotatedTypeFactory::visitNewClass (node=new StrangeConstructorTypeArgs(new MyClass<>())), the type of the assignment context is: Pair(StrangeConstructorTypeArgs, @Initialized @NonNull StrangeConstructorTypeArgs<V extends @Initialized @Nullable Object>), which is not good enough for MyClass<>(). (But I suppose it is good enough for returning value?) By using the context, the type of MyClass<>() would be resolved into MyClass<Object> and cached, which would cause a crush later when checking the arguments,

error: AnnotatedTypeMirrors aren't structurally equal.
    type1 = AnnotatedDeclaredType( @Initialized @NonNull Object )
    type2 = AnnotatedArrayType( @Initialized @NonNull byte @Initialized @NonNull [] )
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@2a798d51
  Compilation unit: /home/pu/checker-framework/checker/tests/all-systems/Issue2302.java
  Last visited tree at line 17 column 16:
          return new StrangeConstructorTypeArgs(new MyClass<>());
  Exception: java.lang.Throwable; Stack trace: org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:14)
  org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.defaultAction(AbstractAtmComboVisitor.java:52)
  org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:68)
  org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:31)
  org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitDeclared_Array(AbstractAtmComboVisitor.java:123)
  org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:303)
  org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:110)
  org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:122)
  org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:308)
  org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:338)
  org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:525)
  org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:476)
  org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:41)
  org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:307)
  org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:182)
  org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:158)
  org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2319)
  org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:205)
  org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:2239)
  org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:188)
  org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:2815)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitNewClass(BaseTypeVisitor.java:1552)
  org.checkerframework.checker.nullness.NullnessVisitor.visitNewClass(NullnessVisitor.java:557)
  org.checkerframework.checker.nullness.NullnessVisitor.visitNewClass(NullnessVisitor.java:55)
  com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1705)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:301)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:167)
  com.sun.source.util.TreeScanner.visitReturn(TreeScanner.java:469)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitReturn(BaseTypeVisitor.java:1657)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitReturn(BaseTypeVisitor.java:167)
  com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1548)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:301)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:167)
  com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
  com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:301)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:167)
  com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
  org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:106)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:687)
  org.checkerframework.checker.initialization.InitializationVisitor.visitMethod(InitializationVisitor.java:337)
  org.checkerframework.checker.initialization.InitializationVisitor.visitMethod(InitializationVisitor.java:52)
  com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:88)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:301)
  org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:167)
  com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:94)
  org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:388)
  org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:295)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:343)
  org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:167)
  com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:82)
  org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1020)
  org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:522)
  org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:182)
  com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
  com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1363)
  com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:959)
  com.sun.tools.javac.main.Main.compile(Main.java:302)
  com.sun.tools.javac.main.Main.compile(Main.java:162)
  com.sun.tools.javac.Main.compile(Main.java:57)
  com.sun.tools.javac.Main.main(Main.java:43)
1 error

I am wondering if the context should be updated when visiting the arguments.
Btw, it does not crush on interning and regex, which not using that method to visit new class.

Originally posted by @abslamp in #2807 (comment)

@wmdietl
Copy link
Member Author

wmdietl commented Oct 31, 2019

Moving this discussion from a merged PR to this new issue.
@abslamp Can you provide a pull request that allows us to reproduce this crash?

@abslamp abslamp self-assigned this Oct 31, 2019
@abslamp
Copy link
Contributor

abslamp commented Nov 1, 2019

Seems not crushing on the latest master branch.

Crush prevented by a previous workaround. PR coming soon.

@smillst
Copy link
Member

smillst commented Feb 28, 2022

I can no longer reproduce this crash. I believe it was fixed by #4929

@smillst smillst closed this as completed Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants