Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when trying to use list<string> #171

Open
cataggar opened this issue Dec 17, 2024 · 2 comments
Open

panic when trying to use list<string> #171

cataggar opened this issue Dec 17, 2024 · 2 comments

Comments

@cataggar
Copy link
Contributor

cataggar commented Dec 17, 2024

Thanks for fixing #166 in #168. I was able to get the JavaScript comopnent to use a Rust component and have it used in a Rust component. When I try to use get-arguments: func() -> list<string>; from the JavaScript component it panics, but works fine with hello: func() -> string;.

interface types {
    resource system {
        constructor();
        get-arguments: func() -> list<string>;
        hello: func() -> string;
    }
}
~/ms/StarlingMonkey15> bun run build.ts
$ wkg wit fetch

$ cargo component build
  Generating bindings for typescript-system (src/bindings.rs)
   Compiling typescript-system v0.1.0 (/Users/cataggar/ms/StarlingMonkey15/typescript-system)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s
    Creating component target/wasm32-wasip1/debug/typescript_system.wasm

$ wkg wit fetch

$ bunx jco types wit -o .

  Generated Type Files:

 - ./interfaces/ts-typescript-system-types.d.ts  0.16 KiB
 - ./interfaces/ts-typescript-typescript.d.ts    0.25 KiB
 - ./interfaces/wasi-io-poll.d.ts                1.36 KiB
 - ./wit.d.ts                                    0.28 KiB


$ bun run bundle.ts

$ bunx jco componentize world.js --wit wit -o ts-typescript.wasm -d all
OK Successfully written ts-typescript.wasm.

$ wkg wit fetch

$ cargo component build
  Generating bindings for test-rs (src/bindings.rs)
   Compiling test-rs v0.1.0 (/Users/cataggar/ms/StarlingMonkey15/test-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
    Creating component target/wasm32-wasip1/debug/test-rs.wasm

$ wac plug target/wasm32-wasip1/debug/test-rs.wasm -o target/test.wasm --plug ../typescript/ts-typescript.wasm

$ wac plug target/test.wasm -o target/test2.wasm --plug ../typescript-system/target/wasm32-wasip1/debug/typescript_system.wasm

$ WASMTIME_BACKTRACE_DETAILS=1 wasmtime run target/test2.wasm a b c
Error: failed to run main module `target/test2.wasm`

Caused by:
    0: failed to invoke `run` function
    1: error while executing at wasm backtrace:
           0: 0x214216 - <unknown>!<wasm function 140>
           1: 0x21421f - <unknown>!<wasm function 141>
           2: 0x418622 - <unknown>!<wasm function 4967>
           3: 0x9911cb - <unknown>!ts:typescript/[email protected]#[method]program.concat-arguments
           4:  0x167 - <unknown>!<wasm function 7>
           5: 0xe67938 - wit-component:shim!indirect-ts:typescript/[email protected][method]program.concat-arguments
           6: 0xc22350 - test_rs::bindings::ts::typescript::typescript::Program::concat_arguments::hb0488eb1671ca607
                           at /Users/cataggar/ms/StarlingMonkey15/test-rs/src/bindings.rs:89:25
           7: 0xc23134 - test_rs::main::h692cc828dd231e3d
                           at /Users/cataggar/ms/StarlingMonkey15/test-rs/src/main.rs:8:20
           8: 0xc22dca - core::ops::function::FnOnce::call_once::hbdd50cb57cdd17d7
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
           9: 0xc22979 - std::sys::backtrace::__rust_begin_short_backtrace::h7c8f96b7bf4677a5
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
          10: 0xc21e3d - std::rt::lang_start::{{closure}}::h2dd43ab9810fe77f
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:162:18
          11: 0xc35d2c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hda5cc35229b3e2d7
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:284:13              - std::panicking::try::do_call::h0757ac3fec725a99
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40              - std::panicking::try::h812b834d48089f5c
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19              - std::panic::catch_unwind::hbe21da14a7442526
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14              - std::rt::lang_start_internal::{{closure}}::h5f6564c4db031e37
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:48              - std::panicking::try::do_call::h09de3a5111bf0861
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40              - std::panicking::try::h1d0b07860d5981d0
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19              - std::panic::catch_unwind::haad2596de262ec59
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14              - std::rt::lang_start_internal::hdc680a054eeeacf1
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:20
          12: 0xc21dd9 - std::rt::lang_start::hbf668ad2f05c9ebb
                           at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:161:17
          13: 0xc23282 - test_rs-6fa4481e8149828b.wasm!__main_void
          14: 0xc21b18 - test_rs-6fa4481e8149828b.wasm!_start
          15: 0xe64e1f - wit-component:adapter:wasi_snapshot_preview1!wasi:cli/[email protected]#run
    2: wasm trap: wasm `unreachable` instruction executed
error: script "run" exited with code 134

In 'test-rs' script 'run' failed with exit code 134
@cataggar
Copy link
Contributor Author

cataggar commented Dec 17, 2024

Steps to reproduce:

git clone [email protected]:cataggar/StarlingMonkey15.git --no-checkout
cd StarlingMonkey15
git checkout ComponentizeJS171
bun install
bun run build.ts

This is using local copies of jco and ComponentizeJS. Freshly built. Assumes they are sibling folders.
"@bytecodealliance/jco": "file:../../jco"
"@bytecodealliance/componentize-js": "file:../ComponentizeJS",

@cataggar
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant