Stack switching: a suspended cross-component call lets another call's borrowed resource be dropped
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust, wasm
調査の方向性
Start by running the supplied WAST test with cargo run -- wast -W stack-switching foo.wast and compare it with the variant that omits the resume in $resume-then-drop. The issue does not name Wasmtime source files or existing tests to trace, so first locate the stack switching and borrowed resource handling code and its related tests. Done means the supplied assert_trap observes the expected "cannot remove owned resource while borrowed" trap.
索引モデルが issue の本文から書いたものです。
説明
This test:
(component
;; `t`'s destructor calls whatever function is in slot 0 of this table.
(core module $D
(table (export "tbl") 1 funcref)
(type $f (func))
(func (export "dtor") (param i32) (call_indirect (type $f) (i32.const 0))))
(core instance $d (instantiate $D))
(type $t (resource (rep i32) (dtor (core func $d "dtor"))))
;; `f` drops the `t` it's given, then returns `self`'s rep, plus 1000000 if
;; `self` was destroyed in the meantime.
(component $B
(import "t" (type $t (sub resource)))
(core func $t.drop (canon resource.drop $t))
(core module $m
(import "" "t.drop" (func $t.drop (param i32)))
(global $dropped (mut i32) (i32.const 0))
(func (export "dtor") (param i32) (global.set $dropped (local.get 0)))
(func (export "f") (param $rep i32) (param $t i32) (result i32)
(call $t.drop (local.get $t))
(if (result i32) (i32.eq (global.get $dropped) (local.get $rep))
(then (i32.add (local.get $rep) (i32.const 1000000)))
(else (local.get $rep)))))
(core instance $i (instantiate $m
(with "" (instance (export "t.drop" (func $t.drop))))))
(type $r' (resource (rep i32) (dtor (core func $i "dtor"))))
(export $r "r" (type $r'))
(core func $r.new (canon resource.new $r))
(func (export "new") (param "rep" u32) (result (own $r)) (canon lift (core func $r.new)))
(func (export "f") (param "self" (borrow $r)) (param "t" (own $t)) (result u32)
(canon lift (core func $i "f"))))
(instance $b (instantiate $B (with "t" (type $t))))
(alias export $b "r" (type $r))
(core func $new (canon lower (func $b "new")))
(core func $f (canon lower (func $b "f")))
(core func $r.drop (canon resource.drop $r))
(core func $t.new (canon resource.new $t))
(core module $O
(import "" "new" (func $new (param i32) (result i32)))
(import "" "f" (func $f (param i32 i32) (result i32)))
(import "" "r.drop" (func $r.drop (param i32)))
(import "" "t.new" (func $t.new (param i32) (result i32)))
(import "" "tbl" (table 1 funcref))
(type $ft (func))
(type $ct (cont $ft))
(tag $tag)
(global $hb (mut i32) (i32.const 0))
(global $k (mut (ref null $ct)) (ref.null $ct))
(func $suspend (suspend $tag))
(func $resume-then-drop
(resume $ct (global.get $k))
(call $r.drop (global.get $hb)))
(func $body
(drop (call $f (call $new (i32.const 11)) (call $t.new (i32.const 0)))))
(elem declare func $suspend $resume-then-drop $body)
(func (export "run") (result i32)
;; Start `f(a)` on a continuation and suspend it from `t`'s destructor.
(table.set (i32.const 0) (ref.func $suspend))
(block $on (result (ref $ct))
(resume $ct (on $tag $on) (cont.new $ct (ref.func $body)))
unreachable)
(global.set $k)
;; Call `f(b)`. From `t`'s destructor, finish `f(a)`, then drop `b`
;; while `f(b)` is still borrowing it.
(table.set (i32.const 0) (ref.func $resume-then-drop))
(global.set $hb (call $new (i32.const 22)))
(call $f (global.get $hb) (call $t.new (i32.const 0)))))
(core instance $o (instantiate $O (with "" (instance
(export "new" (func $new))
(export "f" (func $f))
(export "r.drop" (func $r.drop))
(export "t.new" (func $t.new))
(export "tbl" (table $d "tbl"))))))
(func (export "run") (result u32) (canon lift (core func $o "run"))))
(assert_trap (invoke "run") "cannot remove owned resource while borrowed")
fails with:
$ cargo run -- wast -W stack-switching foo.wast
Error: failed to run script file 'foo.wast'
Caused by:
0: failed directive on foo.wast:77
1: expected trap, got Component([U32(1000022)])
Without the resume in $resume-then-drop, the drop traps with "cannot remove owned resource while borrowed" as expected.
- 主要言語
- Rust
- スター
- 18.9k
- フォーク
- 2k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 238
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/wasmtime のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/wasmtime#15536 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/wasmtime#15455 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
wasi-preview1-component-adapter: fd_write does not invalidate cached InputStream, causing stale reads対応中かも @dpfens が 13 日前に担当しました。 オープンwasi
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bytecodealliance/wasmtime#15296 ·
メンテナーはふだん 1 日以内に返信
-
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 日以内に返信
bytecodealliance/wasmtime の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
area: plugins bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
clipy-recorder/clipy#1039 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
valkey-io/valkey-glide#7975 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gofractally/psibase#2379 ·
メンテナーはふだん 3 日以内に返信
-
Qwen stream parser: a chunk with "error": null is treated as a stream error対応中かも @Beehtrix が今日担当しました。 オープンarea:models bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
brekkylab/ailoy#681 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信