Summary
We use JavaScript and Rust to construct a Wasm component and execute that in wasmtime and jco.
Wasmtime sucessfully print the result, however, jco crashed.
repo: https://github.com/xiaozzzZZzzz240/jco_issue_1390
Environment
jco 1.16.1
wasmtime 41.0.0
OS: macOS Sequoia 15.7
CPU: Intel Core i7
Reproduce steps
The specific reproduction steps are as follows:
-
Use the following command to generate JavaScript binding files from generated_wit_00000.wit.
jco guest-types xxx/witfiles/package3hl16smu1p --world-name world0-pvwxtgtmlk --out-dir xxx/javascript/world0-pvwxtgtmlk
-
Implement the JavaScript program as shown in the javascript directory shown in the repo.
-
Use the following command to generate Wasm component file from JavaScript.
jco componentize xxx/javascript/world0-pvwxtgtmlk/world0-pvwxtgtmlk_generated.js --wit xxx/witfiles/package3hl16smu1p --world-name world0-pvwxtgtmlk --disable http fetch-event --out xxx/componentfiles/world0-pvwxtgtmlk_fromJavaScript.wasm
-
Use the following command to generate Rust binding files from generated_wit_00000b.wit.
wit-bindgen rust xxx/witfiles/package3hl16smu1p --world world1-consumer --generate-all --out-dir xxx/rust/world1-consumer/wit_bindings
-
Implement the Rust program as shown in the rust directory shown in the repo.
-
Use the following command to generate Wasm component file from Rust.
cd xxx/rust/world1-consumer
cargo build --target wasm32-wasip2
-
Use wac to combine the two Wasm component files:
wac plug xxx/componentfiles/world1-consumer_fromRust.wasm --plug xxx/componentfiles/world0-pvwxtgtmlk_fromJavaScript.wasm -o xxx/componentfiles/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasm
-
Use wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasm
Wasmtime prints:
[diag-single] borrow1=f1
[diag-single] size1=101
[diag-single] borrow2=f1
[diag-single] size2=101
- Use jco to run the same final Wasm component file:
jco run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasm
jco prints:
[diag-single] borrow1=f1
can't access property "rep", repTable.get(...) is undefined
Stack:
export_itf0Tmmdqdfhit$file$method$size@/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/74940e2374ce/sources/initializer.js:12091:23
Redirecting call to abort() to mozalloc_abort
RuntimeError: unreachable
at wasm://wasm/0321339a:wasm-function[12489]:0x885bee
at wasm://wasm/0321339a:wasm-function[4582]:0x1abaef
at mydefined:package3hl16smu1p/itf0-tmmdqdfhit#[method]file.size (wasm://wasm/0321339a:wasm-function[12701]:0x89d101)
at wasm://wasm/c4656136:wasm-function[8]:0x16b
at withinwit_rust_component.wasm._ZN24withinwit_rust_component12wit_bindings9mydefined17package3hl16smu1p15itf0_tmmdqdfhit4File4size17h09e5035072f9c394E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[22]:0x9b6)
at withinwit_rust_component.wasm._ZN126_$LT$withinwit_rust_component..Component$u20$as$u20$withinwit_rust_component..wit_bindings..exports..wasi..cli..run..Guest$GT$3run17hf6a1a59ac95c8ea4E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[34]:0xe41)
at withinwit_rust_component.wasm._ZN24withinwit_rust_component12wit_bindings7exports4wasi3cli3run16_export_run_cabi17h276ae912c2818d67E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[37]:0x1016)
at withinwit_rust_component.wasm.wasi:cli/run@0.2.0#run (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[35]:0xfab)
at fn (file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/AmyRXE/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.js:31647:15)
at _withGlobalCurrentTaskMeta (file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/AmyRXE/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.js:451:12)
Simplified reproduction steps
- Use wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasm
Wasmtime prints:
[diag-single] borrow1=f1
[diag-single] size1=101
[diag-single] borrow2=f1
[diag-single] size2=101
- Use jco to run the same final Wasm component file:
jco run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasm
jco prints:
[diag-single] borrow1=f1
can't access property "rep", repTable.get(...) is undefined
Stack:
export_itf0Tmmdqdfhit$file$method$size@/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/74940e2374ce/sources/initializer.js:12091:23
Redirecting call to abort() to mozalloc_abort
RuntimeError: unreachable
at wasm://wasm/0321339a:wasm-function[12489]:0x885bee
at wasm://wasm/0321339a:wasm-function[4582]:0x1abaef
at mydefined:package3hl16smu1p/itf0-tmmdqdfhit#[method]file.size (wasm://wasm/0321339a:wasm-function[12701]:0x89d101)
at wasm://wasm/c4656136:wasm-function[8]:0x16b
at withinwit_rust_component.wasm._ZN24withinwit_rust_component12wit_bindings9mydefined17package3hl16smu1p15itf0_tmmdqdfhit4File4size17h09e5035072f9c394E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[22]:0x9b6)
at withinwit_rust_component.wasm._ZN126_$LT$withinwit_rust_component..Component$u20$as$u20$withinwit_rust_component..wit_bindings..exports..wasi..cli..run..Guest$GT$3run17hf6a1a59ac95c8ea4E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[34]:0xe41)
at withinwit_rust_component.wasm._ZN24withinwit_rust_component12wit_bindings7exports4wasi3cli3run16_export_run_cabi17h276ae912c2818d67E (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[37]:0x1016)
at withinwit_rust_component.wasm.wasi:cli/run@0.2.0#run (wasm://wasm/withinwit_rust_component.wasm-00aef5b6:wasm-function[35]:0xfab)
at fn (file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/AmyRXE/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.js:31647:15)
at _withGlobalCurrentTaskMeta (file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/AmyRXE/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.js:451:12)
Summary
We use JavaScript and Rust to construct a Wasm component and execute that in wasmtime and jco.
Wasmtime sucessfully print the result, however, jco crashed.
repo: https://github.com/xiaozzzZZzzz240/jco_issue_1390
Environment
jco 1.16.1
wasmtime 41.0.0
OS: macOS Sequoia 15.7
CPU: Intel Core i7
Reproduce steps
The specific reproduction steps are as follows:
Use the following command to generate JavaScript binding files from generated_wit_00000.wit.
jco guest-types xxx/witfiles/package3hl16smu1p --world-name world0-pvwxtgtmlk --out-dir xxx/javascript/world0-pvwxtgtmlkImplement the JavaScript program as shown in the javascript directory shown in the repo.
Use the following command to generate Wasm component file from JavaScript.
jco componentize xxx/javascript/world0-pvwxtgtmlk/world0-pvwxtgtmlk_generated.js --wit xxx/witfiles/package3hl16smu1p --world-name world0-pvwxtgtmlk --disable http fetch-event --out xxx/componentfiles/world0-pvwxtgtmlk_fromJavaScript.wasmUse the following command to generate Rust binding files from generated_wit_00000b.wit.
wit-bindgen rust xxx/witfiles/package3hl16smu1p --world world1-consumer --generate-all --out-dir xxx/rust/world1-consumer/wit_bindingsImplement the Rust program as shown in the rust directory shown in the repo.
Use the following command to generate Wasm component file from Rust.
cd xxx/rust/world1-consumercargo build --target wasm32-wasip2Use wac to combine the two Wasm component files:
wac plug xxx/componentfiles/world1-consumer_fromRust.wasm --plug xxx/componentfiles/world0-pvwxtgtmlk_fromJavaScript.wasm -o xxx/componentfiles/world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasmUse wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasmWasmtime prints:
jco run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasmjco prints:
Simplified reproduction steps
wasmtime run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasmWasmtime prints:
jco run world1-consumer_fromRust_importworld0-pvwxtgtmlk_fromJavaScript.wasmjco prints: