Skip to content

Verifier crashes on an assignment to a field of a class that cannot be resolved #426

Open
GadiVenkatesh/liquidjava
#1

Description

@CatarinaGamboa

Impact: verification stops with an internal error on an assignment to a field of a class that cannot be resolved: 4 of the 74 real-world files below (3 projects).

Description

Writing a field whose declaration is not available (opts.sampleSize = 1 with Options not on the classpath): RefinementTypeChecker.checkAssignment (RefinementTypeChecker.java:850) passes the missing declaration to TypeChecker.checkVariableRefinements, and getRefinementFromAnnotation calls getAnnotations() on null (TypeChecker.java:111). #390 fixed the read of such a field; this is the write. A field without a declaration has no refinement to check, so the assignment could be skipped.

Minimal reproducer (com.example.missing is not on the classpath)

import com.example.missing.Options;

public class Repro {
    void configure() {
        Options opts = new Options();
        opts.sampleSize = 1;
    }
}

Expected

Correct! Passed Verification. (with the usual "Java compilation encountered issues" warning).

Actual

Exception in thread "main" java.lang.RuntimeException: 
Error while checking CtMethodImpl
  on configure() { 
  at /tmp/claude-1000/-home-cvgamboa-git/4a721752-8c76-4314-99f8-baeafc8d523a/scratchpad/issues/fieldwrite/Repro.java:4
  with 
Error while checking CtBlockImpl
  on { 
  at /tmp/claude-1000/-home-cvgamboa-git/4a721752-8c76-4314-99f8-baeafc8d523a/scratchpad/issues/fieldwrite/Repro.java:4
  with 
Error while checking CtAssignmentImpl
  on opts.sampleSize = 1; 
  at /tmp/claude-1000/-home-cvgamboa-git/4a721752-8c76-4314-99f8-baeafc8d523a/scratchpad/issues/fieldwrite/Repro.java:6
...
Caused by: java.lang.NullPointerException: Cannot invoke "spoon.reflect.declaration.CtElement.getAnnotations()" because "element" is null
	at liquidjava.processor.refinement_checker.TypeChecker.getRefinementFromAnnotation(TypeChecker.java:111)
	at liquidjava.processor.refinement_checker.TypeChecker.checkVariableRefinements(TypeChecker.java:363)
	at liquidjava.processor.refinement_checker.RefinementTypeChecker.checkAssignment(RefinementTypeChecker.java:850)

Reproduced on main at 0d489e1 (liquidjava-verifier 0.0.36).

Real-world files that hit it

  • opts.inSampleSize = 1; (Android BitmapFactory.Options): Dathaze20/Music-Player-Tagger (file), before and after its fix
  • fresh.dashboardUrl = ...: spazio17/muralis (file)
  • m.error = true;: gil612/Softwaretechnik_2019 (file)

Context

Found while running LiquidJava on the original repository files of 53 real-world typestate and refinement bugs, each verified on its own as in #396. Related: #308, #390.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreal-world-findingFound when experimenting liquidjava in real world repos or OSS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions