wit-bindgen cpp emits invalid resource handle
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Tái hiện lỗi bằng gói WIT trong wit/ và các source được sinh src/consumer-Cpp/world2b-dthcw81x_generated.cpp và src/consumer-Cpp/world2b_dthcw81x.cpp, sau đó compose và chạy các component bằng các lệnh được cung cấp. Theo dõi lời gọi variant/list<option> tại entry point FCph90o7 được báo cáo và so sánh hành vi của handle được sinh với output mong đợi. Hoàn tất khi trường hợp này đạt đến trap invalid handle sạch có chủ đích thay vì unknown handle index.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary: wit-bindgen-cpp generates invalid resource handles for variant/list<option> params, causing an 'unknown handle index' trap in wasmtime
Reproduction of a wit-bindgen-cpp handle-management defect where C++ components pass invalid resource handles across the component boundary, aborting execution in wasmtime with 'unknown handle index'.
Environment
| component | version |
|---|---|
| OS | macOS 15.7 (Darwin 24.6.0), x86_64 |
| wasmtime | wasmtime 41.0.0 (3dda91692 2026-01-20) |
| jco | 1.16.1 (source checkout, tag jco-v1.16.1) |
| Node.js | v22.22.2 |
| wac | wac-cli 0.8.1 |
| wasi-sdk | 27.0 (wasm32-wasip2-clang/clang++) |
Steps to reproduce
The full chain is: compile the guest sources into a provider component and a consumer component, compose them with wac, then run the composed component. Prebuilt copies of every artifact are included (components/provider.wasm, components/consumer.wasm, composed.wasm), so you can also skip straight to step 5.
-
Clone this repository:
git clone <THIS_REPO_URL> cd <THIS_REPO_DIR> -
Compile the provider component from the JavaScript sources in
src/provider-JavaScript/(toolchain versions in the table above; the WIT package is inwit/):jco componentize src/provider-JavaScript/world2-sbtyzmep_generated.js --wit wit --world-name world2-sbtyzmep --disable http fetch-event --out components/provider.wasm -
Compile the consumer component from the C++ sources in
src/consumer-Cpp/:wasm32-wasip2-clang++ -std=c++23 -fno-exceptions -o components/consumer.wasm -mexec-model=reactor src/consumer-Cpp/world2b-dthcw81x_generated.cpp src/consumer-Cpp/world2b_dthcw81x.cpp src/consumer-Cpp/world2b_dthcw81x_component_type.o -
Compose the two components into one runnable component with wac 0.8.1:
wac plug components/consumer.wasm --plug components/provider.wasm -o composed.wasm -
Run the composed component with wasmtime 41.0.0:
wasmtime run composed.wasm
Expected result
This test case intentionally performs an invalid resource-handle operation at the very end, so the expected behavior is: print the prefix below, then trap cleanly with invalid handle.
"resinst0"
"resinst0"
"bar"
"c2"
true
true
ok(some(c2(some(resource("temres63")))))
((resource("temres64"), "p"), "beta")
"c2"
true
true
"bar"
c0(1)
[some(c1([resource("temres13")]))]
"c1"
true
"temres99"
trap(invalid handle)
(jco on the same file also fails (rc=1), but its output diverges from this reference as well; see Notes below — it is raw differential data, not confirming evidence for this expected output.)
Actual result
Under wasmtime the same composed.wasm exits with rc=1. stdout:
"resinst0"
"resinst0"
"bar"
"c2"
true
true
ok(some(c2(some(resource("temres63")))))
((resource("temres64"), "p"), "beta")
"c2"
true
true
"bar"
stderr:
Error: failed to run main module `/Users/myuser/WASM/myProject/Wasm_component_testing/mycode/execute/reportrepo/G004-wit-bindgen-cpp-emits-invalid-resource-handle-unknown-handle-index/composed.wasm`
Caused by:
0: failed to invoke `run` function
1: error while executing at wasm backtrace:
0: 0x858 - <unknown>!<wasm function 20>
1: 0xd1c000 - wit-component:shim!indirect-mydefined:package3hl16smu1p/itf-sn3qxkhktg-f-cph90o7
2: 0xcc4053 - consumer.wasm!mydefined::package3hl16smu1p::itf_sn3qxkhktg::FCph90o7(mydefined::package3hl16smu1p::itf_sn3qxkhktg::Varnl7r84, std::__2::span<std::__2::optional<mydefined::package3hl16smu1p::itf_sn3qxkhktg::Varnl7r84>, 4294967295ul>)
3: 0xcbdf75 - consumer.wasm!exports::wasi::cli::run::Run()
4: 0xcc428a - consumer.wasm!__wasm_export_wasiX3AcliX2FrunX400X2E2X2E0X23run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
2: unknown handle index 3852
Notes
- Differential evidence — jco on the exact same file: rc=1
"resinst0"
"temres2"
"bar"
"c2"
true
true
ok(some(c2(some(resource("temres63")))))
((resource("temres64"), "p"), "beta")
"c2"
true
true
"bar"
--- stderr ---
can't access property "rep", repTable.get(...) is undefined
Stack:
export_itfSn3qxkhktg$fCph90o7@/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/ca0ba5338ca2/sources/initializer.js:12460:33
Redirecting call to abort() to mozalloc_abort
RuntimeError: unreachable
at wasm://wasm/03286172:wasm-function[12489]:0x885e22
at wasm://wasm/03286172:wasm-function[4582]:0x1abd23
at mydefined:package3hl16smu1p/itf-sn3qxkhktg#f-cph90o7 (wasm://wasm/03286172:wasm-function[12711]:0x89d478)
at wasm://wasm/11dbd7b2:wasm-function[23]:0x8a1
at wit-component:shim.indirect-mydefined:package3hl16smu1p/itf-sn3qxkhktg-f-cph90o7 (wasm://wasm/wit-component:shim-786761ae:wasm-function[3]:0x124)
at consumer.wasm.mydefined::package3hl16smu1p::itf_sn3qxkhktg::FCph90o7(mydefined::package3hl16smu1p::itf_sn3qxkhktg::Varnl7r84, std::__2::span<std::__2::optional<mydefined::package3hl16smu1p::itf_sn3qxkhktg::Varnl7r84>, 4294967295ul>) (wasm://wasm/consumer.wasm-0016dc16:wasm-function[251]:0x6f64)
at consumer.wasm.exports::wasi::cli::run::Run() (wasm://wasm/consumer.wasm-0016dc16:wasm-function[19]:0xe86)
at consumer.wasm.__wasm_export_wasiX3AcliX2FrunX400X2E2X2E0X23run (wasm://wasm/consumer.wasm-0016dc16:wasm-function[258]:0x719b)
at Object.run (file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/ARsKAl/composed.js:30578:13)
at file:///private/var/folders/ng/263gml_52h33wsbthhfjjr980000gn/T/ARsKAl/_run.js:14:15
- Ngôn ngữ chính
- Rust
- Star
- 1.5k
- Fork
- 306
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 21
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/wit-bindgen
-
gen-rust
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bytecodealliance/wit-bindgen#1791 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
gen-rust
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
bytecodealliance/wit-bindgen#1790 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Document build.rs approachĐang mởgen-rust
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
bytecodealliance/wit-bindgen#1787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
gen-c#
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
bytecodealliance/wit-bindgen#1759 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Async exports never free the block of indirect parametersCó thể đã có người làm @Aditya1404Sal đã nhận 37 ngày trước. Đang mởasync
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
bytecodealliance/wit-bindgen#1757 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytecodealliance/wit-bindgen
Issue tương tự
-
lane:collections todo:ticket
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày
-
bugfix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
storytold/designcraft#3662 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Nixitov/Riptide-Native#521 ·
Maintainer thường phản hồi trong vòng 1 ngày