False error: in main, an early return on the args array makes a later state-refined call report "Variable 'args' could not be found"

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

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

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

評価

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

調査の方向性

Start by reproducing the failure with the supplied ZipFileRefinements.java and Client.java examples, then compare the main case with the renamed-method and no-early-return variants. Trace how the verifier handles early returns, method parameters, and @StateRefinement calls; the payload names no repository source files or tests. Done means the reproducer verifies successfully without changing the passing variants.

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

説明

bug

Summary

In a method named main, an early return guarded by the array parameter's length makes a later call with a @StateRefinement fail with Not Found Error: Variable 'xs' could not be found. The same body in a method with any other name verifies.

Minimal reproducer

ZipFileRefinements.java:

import java.util.zip.ZipFile;
import liquidjava.specification.*;

@ExternalRefinementsFor("java.util.zip.ZipFile")
@StateSet({"open", "closed"})
public interface ZipFileRefinements {
    @StateRefinement(to = "open(this)")
    void ZipFile(String name);

    @StateRefinement(from = "open(this)", to = "closed(this)")
    void close();
}

Client.java:

import java.util.zip.ZipFile;

public class Client {
    public static void main(String[] xs) throws java.io.IOException {
        if (xs.length < 1) {
            return;
        }
        ZipFile z = new ZipFile("a.zip");
        z.close();   // Not Found Error: Variable 'xs' could not be found
    }
}

Expected: Correct! Passed Verification.

What changes the result (all with the spec above):

variant result
as above Variable 'xs' could not be found at z.close()
static void main(String[] xs) (not public) same error
renamed to public static void f(String[] xs) passes
no early return (if (...) System.out.println(...)) passes
the return branch removed, or z.close() removed passes
no spec passes

Seen on 1a506fe, f7f366c and main at 19991d3.

Why it matters: real code

A command-line unzip tool (plasma-umass/doppio, classes/util/Unzip.java, MIT):

public static void main(String[] args) {
    if (args.length < 1) {
        System.err.println("Usage: Unzip zipfile prefix");
        return;
    }
    ...
    ZipFile zipFile = new ZipFile(args[0]);
    ...
    zipFile.close();

Checking a usage message and returning at the top of main is common in CLI tools, so any spec'd class used afterwards in main hits this.

Found while checking mined client code against JDK specs (liquid-java/co-specification, verifier probe V33).

主要言語
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 を短くまとめたダイジェスト。