Soundness: try/catch is checked as if the catch block always runs
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Locate where the verifier visits try/catch statements (search the visitor/checker for the try-statement case) and compare it with how if/else merges branch states at the join point — the issue says try/catch is currently sequenced instead of merged. Work out how both branches (normal exit from try, entry into catch at an arbitrary point) should be joined, and how the state after the join relates to the state on entry. Done means both reproducers in the issue report errors, the swapped-value case reports correctly, and existing verification tests still pass; add the reproducers as regression tests.
索引モデルが issue の本文から書いたものです。
説明
Impact: a real bug passes verification (false negative).
Description
The verifier checks try and catch blocks one after the other, so after a try/catch a variable keeps whatever the catch block last assigned. The path where the try finishes normally is lost. An if/else instead merges both branches after the join, and try/catch should be merged the same way.
Also, an exception can be thrown at any point in the try. The catch block should therefore not assume the try ran to completion, or that it never ran at all.
Minimal reproducer
import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@ExternalRefinementsFor("java.lang.Throwable")
@StateSet({"withThrowable", "noThrowable"})
interface ThrowableRefinements {
@StateRefinement(to = "noThrowable(this)")
void Throwable(String message);
@StateRefinement(to = "withThrowable(this)")
void Throwable(String message, Throwable cause);
@StateRefinement(from = "noThrowable(this)", to = "withThrowable(this)")
Throwable initCause(Throwable cause);
}
public class Repro {
static void load() throws Exception { throw new Exception("x"); }
static void m() {
Throwable t = new Throwable("start");
try {
load();
t = new Throwable("try", new RuntimeException()); // withThrowable
} catch (Exception e) {
t = new Throwable("catch"); // noThrowable
}
t.initCause(new RuntimeException()); // not reported, but t is withThrowable if load() returns
}
}
Expected: a State Refinement Error on t.initCause(...), because t may be withThrowable.
Actual: Correct! Passed Verification.
Same bug with value refinements
static void m() {
int y = 0;
try {
load();
y = -5;
} catch (Exception e) {
y = 7;
}
@Refinement("_ > 0")
int z = y; // not reported, but y == -5 if load() returns
}
Actual: Correct! Passed Verification. If the values are swapped (5 in the try, -5 in the catch), the error is reported, but as z == -5 is not a subtype of z > 0: only the catch path is considered.
Found while reviewing #362 (catch parameters, #333).
- 主要言語
- Java
- スター
- 67
- フォーク
- 36
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
liquid-java/liquidjava のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
liquid-java/liquidjava#388 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
liquid-java/liquidjava#373 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
liquid-java/liquidjava#321 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
liquid-java/liquidjava#390 ·
メンテナーはふだん 1 日以内に返信
-
Verifier crashes on `!` (or another unary operator) applied to a call whose type cannot be resolvedオープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
liquid-java/liquidjava#389 ·
メンテナーはふだん 1 日以内に返信
liquid-java/liquidjava の issue をすべて見る
似ている issue
-
[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the results対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/java-sdk#1174 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
module: core
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
bigbluebutton/bigbluebutton#26028 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MetricsHub/metricshub-community#1390 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
apache/rocketmq-dashboard#6331 ·
メンテナーはふだん 5 日以内に返信
-
status: team-only type: dependency-upgrade
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spring-projects/spring-boot#52143 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信