False error: a local declared inside try is "not found" at a call in finally
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reproducing the report: save the Repro class from the issue and run LiquidJava on it to see the Not Found Error at input.close() in the finally. The cause is that the state of input recorded at the end of the try still mentions the block-local length, which is out of scope when the finally checks close(). Done means the repro passes verification and the change does not break the existing tests.
索引モデルが issue の本文から書いたものです。
説明
With the Barista BufferedInputStream spec (read() returns _ >= -1; read(byte[], int, int) refines its length):
import java.io.*;
public class Repro {
static int load(InputStream raw, boolean known) throws IOException {
BufferedInputStream input = new BufferedInputStream(raw);
try {
int cost = 0;
if (known) {
int length = input.read();
if (length >= 0) {
byte[] nonce = new byte[length];
input.read(nonce, 0, length);
}
}
return cost;
} finally {
input.close();
}
}
}
On main 1c6807be (and 321a7321):
Not Found Error: Variable 'length' could not be found
input.close(); (in the finally)
length is a block-local of the try; the state of input recorded in the try (after read(nonce, 0, length)) mentions it, and when the finally checks close() against that state, length is out of scope. Expected: Correct! Passed Verification. (out-of-scope locals should be eliminated or kept as fresh variables when the state flows into the finally / after the block).
Found in a real-code example (secrets-for-android FileUtils, a length-prefixed read in try/finally). Since #366 the example's earlier workaround (guarding with a block instead of an early return) no longer avoids it.
- 主要言語
- Java
- スター
- 69
- フォーク
- 36
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 35
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
liquid-java/liquidjava のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
liquid-java/liquidjava#395 ·
メンテナーはふだん 2 日以内に返信
-
Verifier crashes on a comparison or other binary operator whose operand types cannot be resolved (classes not on the classpath)対応中かも @CatarinaGamboa が 3 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
liquid-java/liquidjava#388 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
liquid-java/liquidjava#373 ·
メンテナーはふだん 2 日以内に返信
-
Soundness: a local variable with a constant's name shadows the constant (Format.JPG read as local JPG)対応中かも @CatarinaGamboa が 3 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
liquid-java/liquidjava#321 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
liquid-java/liquidjava#405 ·
メンテナーはふだん 2 日以内に返信
liquid-java/liquidjava の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/rocketmq-dashboard#6872 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ADORSYS-GIS/token-status-link#168 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ADORSYS-GIS/keycloak-oid4vp-plugin#232 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
devops-thiago/ThrillhouseBot#1132 ·
メンテナーはふだん 1 日以内に返信