Verifier crashes on `++` or `--` on a field of another object (`c.count++`)

オープン
#436 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java

調査の方向性

Start with OperationsChecker.getUnaryOpRefinements and getRefinementUnaryVariableWrite near line 500, then compare the NEG path near line 196. Reproduce with the provided Counter and Repro example, including the ++, --, and unary minus cases. Done when these cases no longer crash and verification reports Correct! Passed Verification.

索引モデルが issue の本文から書いたものです。

説明

bug

Impact: verification stops with an internal error (crash) on ++/-- applied to a field of another object.

Description

c.count++ where c is an object of another class: OperationsChecker.getUnaryOpRefinements names the operand with Utils.qualifyFieldName, and getRefinementUnaryVariableWrite (OperationsChecker.java:500) looks that name up in the context, gets null, and calls substituteVariable on it. The same happens for c.count--, ++c.count, and c.count = -c.count (the NEG path at OperationsChecker.java:196). int k = -c.count, count++ / this.count++, and o.count++ with o of the current class do not crash. When the field has no tracked refinement, the operand could be treated as an unrefined value instead.

Minimal reproducer

class Counter {
    int count;
}

public class Repro {
    void inc(Counter c) {
        c.count++;
    }
}

Expected

Correct! Passed Verification.

Actual

Exception in thread "main" java.lang.RuntimeException: 
Error while checking CtMethodImpl
  on inc(Counter c) { 
  ...
Error while checking CtUnaryOperatorImpl
  on c.count++; 
  at .../Repro.java:7
  with Cannot invoke "liquidjava.rj_language.Predicate.substituteVariable(String, String)" because "metadada" is null
...
Caused by: java.lang.NullPointerException: Cannot invoke "liquidjava.rj_language.Predicate.substituteVariable(String, String)" because "metadada" is null
	at liquidjava.processor.refinement_checker.general_checkers.OperationsChecker.getRefinementUnaryVariableWrite(OperationsChecker.java:501)
	at liquidjava.processor.refinement_checker.general_checkers.OperationsChecker.getUnaryOpRefinements(OperationsChecker.java:183)
	at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitCtUnaryOperator(RefinementTypeChecker.java:387)

The same crash happens when the field's class is not on the classpath (opts.sampleSize++ with Options missing).

Reproduced on main at 1a506fea (liquidjava-verifier 0.0.36).

Context

Found while reviewing #432. Related: #426 (plain assignment to a field of an unresolved class).

🤖 Generated with Claude Code

主要言語
Java
スター
73
フォーク
38
平均マージ
12時間 32分
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

liquid-java/liquidjava のほかの issue

liquid-java/liquidjava の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。