Stream: git-wasmtime

Topic: wasmtime / issue #15300 {stream,future}.cancel-{read,writ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2026 at 15:42):

seunghyun-24 opened issue #15300:

Test Case

;;! component_model_async = true

;; Case 1: stream.cancel-write on a readable end with a pending read.
(component
  (type $t (stream u8))
  (core module $libc (memory (export "mem") 1))
  (core instance $libc (instantiate $libc))
  (core func $new (canon stream.new $t))
  (core func $read (canon stream.read $t async (memory (core memory $libc "mem"))))
  (core func $cancel (canon stream.cancel-write $t))
  (core module $m
    (import "" "new" (func $new (result i64)))
    (import "" "read" (func $read (param i32 i32 i32) (result i32)))
    (import "" "cancel" (func $cancel (param i32) (result i32)))
    (func (export "f") (result i32)
      (local $new i64) (local $end i32)
      (local.set $new (call $new))
      (local.set $end (i32.wrap_i64 (local.get $new)))
      ;; Start a read on the readable end. It blocks because nothing is written.
      (if (i32.ne (call $read (local.get $end) (i32.const 0) (i32.const 1)) (i32.const -1)) (then unreachable))
      ;; Try to cancel a write on the readable end.
      (call $cancel (local.get $end))))
  (core instance $i (instantiate $m
    (with "" (instance
      (export "new" (func $new))
      (export "read" (func $read))
      (export "cancel" (func $cancel))))))
  (func (export "f") async (result u32) (canon lift (core func $i "f"))))
(assert_trap (invoke "f") "passed read end to `{stream|future}.cancel-write`")

The other three combinations are also affected:

The complete test cases are attached in cancel_wrong_end_busy.wast.

Steps to Reproduce

wasmtime wast -W component-model-async=y cancel_wrong_end_busy.wast

Expected Results

The call should trap because the handle refers to a readable end, but cancel-write was called.

Actual Results

The call returns CANCELLED (2) instead of trapping.

Versions and Environment

Extra Info

In a release build the two bail_bug!s surface as traps. In a build with debug assertions they panic (bug.rs:63), as WasmtimeBug::new is written to do.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2026 at 15:42):

seunghyun-24 added the bug label to Issue #15300.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2026 at 15:56):

seunghyun-24 edited issue #15300:

cancel_wrong_end_busy.wast.txt
cancel_wrong_end_followon.wast.txt

Test Case

;;! component_model_async = true

;; Case 1: stream.cancel-write on a readable end with a pending read.
(component
  (type $t (stream u8))
  (core module $libc (memory (export "mem") 1))
  (core instance $libc (instantiate $libc))
  (core func $new (canon stream.new $t))
  (core func $read (canon stream.read $t async (memory (core memory $libc "mem"))))
  (core func $cancel (canon stream.cancel-write $t))
  (core module $m
    (import "" "new" (func $new (result i64)))
    (import "" "read" (func $read (param i32 i32 i32) (result i32)))
    (import "" "cancel" (func $cancel (param i32) (result i32)))
    (func (export "f") (result i32)
      (local $new i64) (local $end i32)
      (local.set $new (call $new))
      (local.set $end (i32.wrap_i64 (local.get $new)))
      ;; Start a read on the readable end. It blocks because nothing is written.
      (if (i32.ne (call $read (local.get $end) (i32.const 0) (i32.const 1)) (i32.const -1)) (then unreachable))
      ;; Try to cancel a write on the readable end.
      (call $cancel (local.get $end))))
  (core instance $i (instantiate $m
    (with "" (instance
      (export "new" (func $new))
      (export "read" (func $read))
      (export "cancel" (func $cancel))))))
  (func (export "f") async (result u32) (canon lift (core func $i "f"))))
(assert_trap (invoke "f") "passed read end to `{stream|future}.cancel-write`")

The other three combinations are also affected:

The complete test cases are attached in cancel_wrong_end_busy.wast.

Steps to Reproduce

wasmtime wast -W component-model-async=y cancel_wrong_end_busy.wast

Expected Results

The call should trap because the handle refers to a readable end, but cancel-write was called.

Actual Results

The call returns CANCELLED (2) instead of trapping.

Versions and Environment

Extra Info

In a release build the two bail_bug!s surface as traps. In a build with debug assertions they panic (bug.rs:63), as WasmtimeBug::new is written to do.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 17 2026 at 17:17):

alexcrichton closed issue #15300:

cancel_wrong_end_busy.wast.txt
cancel_wrong_end_followon.wast.txt

Test Case

;;! component_model_async = true

;; Case 1: stream.cancel-write on a readable end with a pending read.
(component
  (type $t (stream u8))
  (core module $libc (memory (export "mem") 1))
  (core instance $libc (instantiate $libc))
  (core func $new (canon stream.new $t))
  (core func $read (canon stream.read $t async (memory (core memory $libc "mem"))))
  (core func $cancel (canon stream.cancel-write $t))
  (core module $m
    (import "" "new" (func $new (result i64)))
    (import "" "read" (func $read (param i32 i32 i32) (result i32)))
    (import "" "cancel" (func $cancel (param i32) (result i32)))
    (func (export "f") (result i32)
      (local $new i64) (local $end i32)
      (local.set $new (call $new))
      (local.set $end (i32.wrap_i64 (local.get $new)))
      ;; Start a read on the readable end. It blocks because nothing is written.
      (if (i32.ne (call $read (local.get $end) (i32.const 0) (i32.const 1)) (i32.const -1)) (then unreachable))
      ;; Try to cancel a write on the readable end.
      (call $cancel (local.get $end))))
  (core instance $i (instantiate $m
    (with "" (instance
      (export "new" (func $new))
      (export "read" (func $read))
      (export "cancel" (func $cancel))))))
  (func (export "f") async (result u32) (canon lift (core func $i "f"))))
(assert_trap (invoke "f") "passed read end to `{stream|future}.cancel-write`")

The other three combinations are also affected:

The complete test cases are attached in cancel_wrong_end_busy.wast.

Steps to Reproduce

wasmtime wast -W component-model-async=y cancel_wrong_end_busy.wast

Expected Results

The call should trap because the handle refers to a readable end, but cancel-write was called.

Actual Results

The call returns CANCELLED (2) instead of trapping.

Versions and Environment

Extra Info

In a release build the two bail_bug!s surface as traps. In a build with debug assertions they panic (bug.rs:63), as WasmtimeBug::new is written to do.


Last updated: Nov 19 2026 at 20:05 UTC