Skip to content

Possible to drop a future writable end without ever writing #13661

@alexcrichton

Description

@alexcrichton

This test:

(component
  (core module $libc (memory (export "m") 1))
  (core instance $libc (instantiate $libc))

  (type $f (future u8))
  (core func $future.new (canon future.new $f))
  (core func $future.drop-readable (canon future.drop-readable $f))
  (core func $future.drop-writable (canon future.drop-writable $f))

  (core module $m
    (import "" "m" (memory 1))
    (import "" "future.new" (func $future.new (result i64)))
    (import "" "future.drop-readable" (func $future.drop-readable (param i32)))
    (import "" "future.drop-writable" (func $future.drop-writable (param i32)))

    (func (export "run")
      (local $tmp i64) (local $r i32) (local $w i32)
      (local.set $tmp (call $future.new))
      (local.set $r (i32.wrap_i64 (local.get $tmp)))
      (local.set $w (i32.wrap_i64 (i64.shr_u (local.get $tmp) (i64.const 32))))
      (call $future.drop-readable (local.get $r))
      (call $future.drop-writable (local.get $w))
    )
  )
  (core instance $i (instantiate $m
    (with "" (instance
      (export "m" (memory $libc "m"))
      (export "future.new" (func $future.new))
      (export "future.drop-readable" (func $future.drop-readable))
      (export "future.drop-writable" (func $future.drop-writable))
    ))
  ))
  (func (export "run") async (canon lift (core func $i "run")))
)
(assert_trap (invoke "run") "something here")

creates a future, closed the read end, then closes the write end. I think this should be trap, but currently Wasmtime executes this.

cc @dicej - would you be able to take a look at this?

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions