cplusplus.zip
generated_wit_00000.wit.zip
generated_wit_00000b.wit.zip
python.zip
world0-pvwxtgtmlk_fromPython.wasm.zip
world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm.zip
world1-consumer_fromC++.wasm.zip
Summary
Using these two WIT files, we implemented them in C++ and Python respectively, and finally compiled them into Wasm component files. We executed them in wasmtime and jco. wasmtime ran correctly, but jco crashed.
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 Python binding files from generated_wit_00000.wit.
componentize-py -d xxx/witfiles/package3hl16smu1p -w world0-pvwxtgtmlk bindings xxx/python/world0-pvwxtgtmlk
-
Implement the Python program as shown in python.zip.
-
Use the following command to generate Wasm component file from Python.
cd xxx/python/world0-pvwxtgtmlk
componentize-py --wit-path xxx/witfiles/package3hl16smu1p --world world0-pvwxtgtmlk componentize world0-pvwxtgtmlk_generated -o xxx/componentfiles/world0-pvwxtgtmlk_fromPython.wasm
-
Use the following command to generate C++ binding files from generated_wit_00000b.wit.
wit-bindgen cpp xxx/witfiles/package3hl16smu1p --world world1-consumer --out-dir xxx/cplusplus/world1-consumer
-
Implement the C++ program as shown in cplusplus.zip.
-
Use the following command to generate Wasm component file from C++.
xxx/WASI/wasi-sdk-27.0/wasi-sdk-27.0-x86_64-macos/bin/wasm32-wasip2-clang++ -std=c++23 -o xxx/componentfiles/world1-consumer_fromC++.wasm -mexec-model=reactor xxx/cplusplus/world1-consumer/world1-consumer_generated.cpp xxx/cplusplus/world1-consumer/world1_consumer.cpp xxx/cplusplus/world1-consumer/world1_consumer_component_type.o
-
Use wac to combine the two Wasm component files:
wac plug xxx/componentfiles/world1-consumer_fromC++.wasm --plug xxx/componentfiles/world0-pvwxtgtmlk_fromPython.wasm -o xxx/componentfiles/world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm
-
Use wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm
Wasmtime prints:
[dbg] run: minimal begin
[dbg] py: open_temp begin
[dbg] py: handle.__init__ path=mem://h-1
[dbg] py: open_temp end path=mem://h-1
[dbg] run: before append
[dbg] py: handle.append begin path=mem://h-1 data=|x|
[dbg] py: handle.append end path=mem://h-1 size=3
[dbg] run: after append
- Use jco to run the same final Wasm component file:
jco run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm
jco prints:
[dbg] run: minimal begin
[dbg] py: open_temp begin
[dbg] py: handle.__init__ path=mem://h-1
[dbg] py: open_temp end path=mem://h-1
[dbg] run: before append
AttributeError: '' object has no attribute 'append'
thread '<unnamed>' panicked at runtime/src/lib.rs:499:21:
Python function threw an unexpected exception
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
RuntimeError: unreachable
at libc.so.abort (wasm://wasm/libc.so-001e65fe:wasm-function[458]:0x1041d)
at wasm://wasm/02a675a6:wasm-function[306]:0xf8e8
at libcomponentize_py_runtime.so.std::sys::pal::wasi::helpers::abort_internal::h118dde344a79086c (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2193]:0xceb72)
at libcomponentize_py_runtime.so.std::process::abort::h2738589d00d7233e (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1645]:0xb87f6)
at libcomponentize_py_runtime.so.__rustc::__rust_abort (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2002]:0xc7330)
at libcomponentize_py_runtime.so.__rustc::__rust_start_panic (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2208]:0xcfc4c)
at libcomponentize_py_runtime.so.__rustc::rust_panic (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2035]:0xc8a1e)
at libcomponentize_py_runtime.so.std::panicking::rust_panic_with_hook::h02d894de16d94192 (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2034]:0xc899c)
at libcomponentize_py_runtime.so.std::panicking::begin_panic_handler::_$u7b$$u7b$closure$u7d$$u7d$::he125d401eefa4f33 (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1573]:0xb451a)
at libcomponentize_py_runtime.so.std::sys::backtrace::__rust_end_short_backtrace::h31a9416a2c4ea1cb (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1572]:0xb4442)
Simplified reproduction steps
- Use wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm
Wasmtime prints:
[dbg] run: minimal begin
[dbg] py: open_temp begin
[dbg] py: handle.__init__ path=mem://h-1
[dbg] py: open_temp end path=mem://h-1
[dbg] run: before append
[dbg] py: handle.append begin path=mem://h-1 data=|x|
[dbg] py: handle.append end path=mem://h-1 size=3
[dbg] run: after append
- Use jco to run the same final Wasm component file:
jco run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm
jco prints:
[dbg] run: minimal begin
[dbg] py: open_temp begin
[dbg] py: handle.__init__ path=mem://h-1
[dbg] py: open_temp end path=mem://h-1
[dbg] run: before append
AttributeError: '' object has no attribute 'append'
thread '<unnamed>' panicked at runtime/src/lib.rs:499:21:
Python function threw an unexpected exception
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
RuntimeError: unreachable
at libc.so.abort (wasm://wasm/libc.so-001e65fe:wasm-function[458]:0x1041d)
at wasm://wasm/02a675a6:wasm-function[306]:0xf8e8
at libcomponentize_py_runtime.so.std::sys::pal::wasi::helpers::abort_internal::h118dde344a79086c (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2193]:0xceb72)
at libcomponentize_py_runtime.so.std::process::abort::h2738589d00d7233e (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1645]:0xb87f6)
at libcomponentize_py_runtime.so.__rustc::__rust_abort (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2002]:0xc7330)
at libcomponentize_py_runtime.so.__rustc::__rust_start_panic (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2208]:0xcfc4c)
at libcomponentize_py_runtime.so.__rustc::rust_panic (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2035]:0xc8a1e)
at libcomponentize_py_runtime.so.std::panicking::rust_panic_with_hook::h02d894de16d94192 (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[2034]:0xc899c)
at libcomponentize_py_runtime.so.std::panicking::begin_panic_handler::_$u7b$$u7b$closure$u7d$$u7d$::he125d401eefa4f33 (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1573]:0xb451a)
at libcomponentize_py_runtime.so.std::sys::backtrace::__rust_end_short_backtrace::h31a9416a2c4ea1cb (wasm://wasm/libcomponentize_py_runtime.so-0052fcc2:wasm-function[1572]:0xb4442)
Result Analysis
The logic of this program is to create a Handle resource, and then call the append method on the resource.
jco prints different result from wasmtime.
The possible reason is that jco handles the resource type as a string type, so it indicates that the string type does not have an append method.
cplusplus.zip
generated_wit_00000.wit.zip
generated_wit_00000b.wit.zip
python.zip
world0-pvwxtgtmlk_fromPython.wasm.zip
world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasm.zip
world1-consumer_fromC++.wasm.zip
Summary
Using these two WIT files, we implemented them in C++ and Python respectively, and finally compiled them into Wasm component files. We executed them in wasmtime and jco. wasmtime ran correctly, but jco crashed.
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 Python binding files from generated_wit_00000.wit.
componentize-py -d xxx/witfiles/package3hl16smu1p -w world0-pvwxtgtmlk bindings xxx/python/world0-pvwxtgtmlkImplement the Python program as shown in python.zip.
Use the following command to generate Wasm component file from Python.
cd xxx/python/world0-pvwxtgtmlkcomponentize-py --wit-path xxx/witfiles/package3hl16smu1p --world world0-pvwxtgtmlk componentize world0-pvwxtgtmlk_generated -o xxx/componentfiles/world0-pvwxtgtmlk_fromPython.wasmUse the following command to generate C++ binding files from generated_wit_00000b.wit.
wit-bindgen cpp xxx/witfiles/package3hl16smu1p --world world1-consumer --out-dir xxx/cplusplus/world1-consumerImplement the C++ program as shown in cplusplus.zip.
Use the following command to generate Wasm component file from C++.
xxx/WASI/wasi-sdk-27.0/wasi-sdk-27.0-x86_64-macos/bin/wasm32-wasip2-clang++ -std=c++23 -o xxx/componentfiles/world1-consumer_fromC++.wasm -mexec-model=reactor xxx/cplusplus/world1-consumer/world1-consumer_generated.cpp xxx/cplusplus/world1-consumer/world1_consumer.cpp xxx/cplusplus/world1-consumer/world1_consumer_component_type.oUse wac to combine the two Wasm component files:
wac plug xxx/componentfiles/world1-consumer_fromC++.wasm --plug xxx/componentfiles/world0-pvwxtgtmlk_fromPython.wasm -o xxx/componentfiles/world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasmUse wasmtime to run the final Wasm component file:
wasmtime run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasmWasmtime prints:
jco run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasmjco prints:
Simplified reproduction steps
wasmtime run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasmWasmtime prints:
jco run world1-consumer_fromC++_importworld0-pvwxtgtmlk_fromPython.wasmjco prints:
Result Analysis
The logic of this program is to create a Handle resource, and then call the append method on the resource.
jco prints different result from wasmtime.
The possible reason is that jco handles the resource type as a string type, so it indicates that the string type does not have an append method.