Read-only access to numeric globals from epoch/call hooks (`StoreHookState`)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Read the Global::get implementation and StoreHookState/AsContext APIs, then review the linked pull request #14979 and the rationale in #14386. Determine whether a read-only numeric global getter fits the callback safety constraints and identify suitable coverage for numeric and reference globals; done means the API decision is resolved and the behavior is covered.
索引モデルが issue の本文から書いたものです。
説明
#14386 narrowed epoch-deadline and call-hook callbacks to StoreHookState, which implements AsContext and gives &mut T. We agree with the rationale: mutating wasm-visible state between instructions is wrong.
That change leaves one read-only use case with no API: reading the current value of a mutable numeric global from inside the callback.
Global::get takes impl AsContextMut. As far as I can tell that is because the Ref arms clone GC refs (clone_gc_ref, ExternRef::from_cloned_gc_ref) and need AutoAssertNoGc. For i32/i64/f32/f64 (and v128) it is a plain load from the VMGlobalDefinition and mutates nothing. So there is no way to read a numeric global with only an AsContext.
Our use case: an embedder that snapshots a suspended guest thread reads the guest's mutable globals (such as the shadow stack pointer) at the moment an epoch tick parks the thread, while the wasm frames are still live on the stack. The thread is paused at a safe point; nothing is mutated, and we do not call back into wasm.
Proposal: a getter that takes impl AsContext and returns Option<Val>/Result<Val> for non-reference global types (returning None/Err for Ref types), e.g. Global::get_numeric. It would be safe to expose from StoreHookState for the same reason Memory::data(&store) already is.
If you would rather not add API surface, is there an intended way for an embedder to observe global values from an epoch callback now? The DebugHandler route (DebugEvent::EpochYield) seems to require guest_debug and async, which is heavier than we want for this.
Happy to send a PR if this direction is acceptable.
- 主要言語
- Rust
- スター
- 18.7k
- フォーク
- 1.9k
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 361
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/wasmtime のほかの issue
-
bug wasm-proposal:exceptions wasmtime:debugging
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bytecodealliance/wasmtime#14102 ·
メンテナーはふだん 1 日以内に返信
-
wasm-proposal:gc
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bytecodealliance/wasmtime#13808 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
cranelift cranelift:area:clif cranelift:goal:optimize-speed enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/wasmtime#1598 · コメント 9 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
bytecodealliance/wasmtime#14989 ·
メンテナーはふだん 1 日以内に返信
-
RUSTSEC-2026-0386: `AsyncFd::new` and related constructors violate I/O safety対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 15/100
bytecodealliance/wasmtime#14977 ·
メンテナーはふだん 1 日以内に返信
bytecodealliance/wasmtime の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
manuscript-lang/manuscript#1364 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
equinor/septic-config-generator#504 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
GiganticMinecraft/seichi-portal-backend#1633 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
fable-compiler/Fable#5157 ·
メンテナーはふだん 1 日以内に返信