Skip to content

FACT can't handle async-to-async adapters using memory64 #13979

Description

@alexcrichton

The component-model-memory64 integration is still a work in progress but I wanted to note this nonetheless.

This input:

(component
  (component $A
    (core module $a
      (memory (export "memory") i64 1)
      (func (export "realloc") (param i64 i64 i64 i64) (result i64) (i64.const 128))
      (func (export "run") (result i32) (i32.const 0))
      (func (export "cb") (param i32 i32 i32) (result i32) (i32.const 0))
    )
    (core instance $a (instantiate $a))
    (type $r (tuple u64 u64 u64))
    (func (export "run") async (result $r)
      (canon lift (core func $a "run") async
        (callback (func $a "cb"))
        (memory $a "memory")
        (realloc (func $a "realloc"))))
  )
  (instance $ia (instantiate $A))

  (component $B
    (type $r (tuple u64 u64 u64))
    (import "run" (func $f async (result $r)))
    (core module $libc
      (memory (export "memory") 1)
      (func (export "realloc") (param i32 i32 i32 i32) (result i32) (i32.const 128))
    )
    (core instance $libc (instantiate $libc))
    (core func $lower
      (canon lower (func $f) (memory $libc "memory") (realloc (func $libc "realloc"))))
    (core module $main
      (import "" "f" (func (param i32)))
      (func (export "run") (call 0 (i32.const 256)))
    )
    (core instance $imain (instantiate $main (with "" (instance (export "f" (func $lower))))))
    (func (export "run") (canon lift (core func $imain "run")))
  )
  (instance $ib (instantiate $B (with "run" (func $ia "run"))))
  (export "run" (func $ib "run"))
)

fails with:

$ cargo run compile async-retptr64.wat -W component-model-memory64
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 20.00s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime compile async-retptr64.wat -W component-model-memory64`

thread 'main' (2603957) panicked at crates/environ/src/fact/trampoline.rs:1093:13:
assertion `left == right` failed
  left: I64
 right: I32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' (2603957) panicked at crates/environ/src/fact/trampoline.rs:4607:13:
temporary local not free'd
stack backtrace:
   0:     0x5ee098ae86e8 - std[bcb96dfbba0ab899]::backtrace_rs::backtrace::libunwind::trace
                               at /rustc/2d8144b7880597b6e6d3dfd63a9a9efae3f533d3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
...
  45:     0x5ee0938d5325 - _start
  46:                0x0 - <unknown>

thread 'main' (2603957) panicked at /rustc/2d8144b7880597b6e6d3dfd63a9a9efae3f533d3/library/core/src/panicking.rs:233:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.
zsh: IOT instruction (core dumped)  cargo run compile async-retptr64.wat -W component-model-memory64

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasm-proposal:component-modelIssues related to the WebAssembly Component Model proposalwasm-proposal:memory64Issues with the implementation of the memory64 wasm proposal

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions