Skip to content

Panic juggling subtasks in wasip3 #12544

@alexcrichton

Description

@alexcrichton

This input:

(component

  (component $a
    (core module $m
      (func (export "a") (result i32) i32.const 1) ;; CALLBACK_CODE_YIELD
      (func (export "cb") (param i32 i32 i32) (result i32) i32.const 1) ;; CALLBACK_CODE_YIELD
    )
    (core instance $i (instantiate $m))
    (func (export "f") async
      (canon lift (core func $i "a") async (callback (func $i "cb"))))
  )

  (component $b
    (import "f" (func $f async))
    (core module $m
      (import "" "f" (func $f (result i32)))
      (import "" "cancel" (func $cancel (param i32) (result i32)))
      (global $subtask (mut i32) (i32.const 0))
      (func (export "a")
        (global.set $subtask
          (i32.shr_u
            (call $f)
            (i32.const 4))))
      (func (export "b")
        (drop (call $cancel (global.get $subtask))))
    )
    (core func $f (canon lower (func $f) async))
    (core func $cancel (canon subtask.cancel))
    (core instance $i (instantiate $m
      (with "" (instance
        (export "f" (func $f))
        (export "cancel" (func $cancel))
      ))
    ))
    (func (export "a") async (canon lift (core func $i "a")))
    (func (export "b") async (canon lift (core func $i "b")))
  )

  (instance $a (instantiate $a))
  (instance $b (instantiate $b (with "f" (func $a "f"))))
  (export "a" (func $b "a"))
  (export "b" (func $b "b"))
)

(assert_return (invoke "a"))
(assert_return (invoke "b"))

fails with:

$ cargo run wast foo.wast -Wcomponent-model-async
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/wasmtime wast foo.wast -Wcomponent-model-async`

thread 'main' (2592575) panicked at crates/wasmtime/src/runtime/component/concurrent.rs:3461:17:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions