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

Đang mở
#436 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend, testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
73
Fork
38
Merge trung bình
12 giờ 32 phút
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của liquid-java/liquidjava

Tất cả issue của liquid-java/liquidjava

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.