StateMachineHoistedLocalScopes rows are not aligned with the hoisted slots
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
330 行目の PortablePdbWriter.BuildStateMachineHoistedLocalScopes から開始し、次に 186-192 行目付近の呼び出し元と、デバッガーがステートマシンのフィールド名からスロット番号を解析する方法を調べます。MixedAsync の例を再現し、生成された行を最も大きいスロットと比較します。完了条件は、行がスロット単位で整列され、必要に応じてプレースホルダーが含まれ、現在の行数を超える hoisted locals も表示されることです。
索引モデルが issue の本文から書いたものです。
説明
Summary
StateMachineHoistedLocalScopes is indexed by slot number: a debugger parses N out of a state machine field name (<name>5__N, <>8__N) and reads row N-1 of the blob. PortablePdbWriter.BuildStateMachineHoistedLocalScopes (line 330) instead emits one row per surviving ILVariable that has a StateMachineField, ordered by field token, and gives every row the extent (0, CodeSize). That sequence has no relation to the slot numbering, so rows are misaligned, and where it is shorter than the highest slot the hoisted locals above the row count are dropped by the expression evaluator.
Reproduction
public static async Task<int> MixedAsync(IEnumerable<int> source)
{
List<int> chunks = new List<int>();
foreach (int value in source)
chunks.Add(value);
await Task.Yield();
int total = 0;
try
{
foreach (int chunk in chunks)
{
total += chunk;
await Task.Yield();
}
}
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
}
return total;
}
State machine fields of <MixedAsync>d__0 (slots 1-7):
<>1__state, <>t__builder, source, <chunks>5__1, <total>5__2, <>s__3,
<value>5__4, <>s__5, <chunk>5__6, <e>5__7, <>u__1
Blob rows for <MixedAsync>d__0.MoveNext, start+length:
compiler: 0+24e, 0+24e, 0+0, 3c+25, 0+0, 124+8c, 1e8+1f
ILSpy: 0+24e, 0+24e, 0+24e, 0+24e, 0+24e, 0+24e, 0+24e
The compiler emits exactly one row per slot, in slot order, with an empty 0+0 placeholder for the synthesized <>s__N slots and the real live range for each user local. ILSpy's rows happen to number seven here, but they enumerate a different set (the hoisted parameter source is included, the <>s__N slots are not), so row N-1 does not describe slot N.
The counts diverge on real code: checking the PDB ILSpy generates against the highest user-visible slot in the binary reports a shortfall in 227 state machines of Newtonsoft.Json 13.0.4 and 2 of Microsoft.Extensions.Http 10.0.11. A shortfall means the hoisted locals whose slot exceeds the row count disappear from the Locals window entirely.
Note
#1230 lists StateMachineHoistedLocalScopes as unimplemented. It is emitted (PortablePdbWriter.cs lines 186-192), just not in the shape a consumer reads.
Posted by an AI agent (Claude) on Siegfried's behalf.
- 主要言語
- C#
- スター
- 27.1k
- フォーク
- 3.8k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/ILSpy のほかの issue
-
External UI
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
icsharpcode/ILSpy#4284 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
icsharpcode/ILSpy#4357 ·
メンテナーはふだん 1 日以内に返信
-
Misdecompilation of a lazy initialization pattern対応中かも @siegfriedpammer が 5 日前に担当しました。 オープンBug Decompiler
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
icsharpcode/ILSpy#4349 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/ILSpy#4343 ·
メンテナーはふだん 1 日以内に返信
-
AI
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/ILSpy#4300 ·
メンテナーはふだん 1 日以内に返信
icsharpcode/ILSpy の issue をすべて見る
似ている issue
-
type:task ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elsa-workflows/elsa-foundation#5253 ·
メンテナーはふだん 1 日以内に返信