C++ bindgen: function with two `own<resource>` args returns an error handle
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先使用 src/provider-Cpp/ 中的 provider 源代码、src/consumer-C/ 中的 consumer 源代码以及提供的 composed.wasm 重现该故障,然后检查返回字符串的 resource 方法所对应的 C++ bindgen 路径。修复完成的标准是:composed component 输出 "temres26" 而不是 "",并且仍然通过列出的 jco 和 wasmtime 运行。
由索引模型根据 Issue 内容生成。
描述
Summary: C++ provider component lifts a non-empty string return value as an empty string.
A wit-bindgen-cpp bug where a C++ provider component returns an empty string in place of the actual string value (e.g. "temres26"), observed consistently across all consumer languages.
Environment
| component | version |
|---|---|
| OS | macOS 15.7 (Darwin 24.6.0), x86_64 |
| 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.
Github repo:https://github.com/xiaozzzZZzzz240/G051-Cplusplus-string-return-from-a-resource-method-comes-back-empty
-
Clone this repository:
git clone <THIS_REPO_URL> cd <THIS_REPO_DIR> -
Compile the provider component from the C++ sources in
src/provider-Cpp/(toolchain versions in the table above; the WIT package is inwit/):wasm32-wasip2-clang++ -std=c++23 -fno-exceptions -o components/provider.wasm -mexec-model=reactor src/provider-Cpp/world69-uvfx7r7j_generated.cpp src/provider-Cpp/world69_uvfx7r7j.cpp src/provider-Cpp/world69_uvfx7r7j_component_type.o -
Compile the consumer component from the C sources in
src/consumer-C/:wasm32-wasip2-clang -o components/consumer.wasm -mexec-model=reactor src/consumer-C/world69b-myhp0jr6_generated.c src/consumer-C/world69b_myhp0jr6.c src/consumer-C/world69b_myhp0jr6_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 jco:
npm install -g @bytecodealliance/[email protected] jco run composed.wasm
Expected result
The composed component should print exactly the following, then exit 0:
"resinst0"
"resinst0"
"foo"
true
true
"temres132"
resource("temres26")
([resource("temres28")], "foo")
true
resource("temres160")
resource("temres161")
true
"temres26"
"temres32"
7
"p"
Actual result
Under jco the same composed.wasm exits with rc=0. stdout:
"resinst0"
"resinst0"
"foo"
true
true
"temres132"
resource("temres26")
([resource("temres28")], "foo")
true
resource("temres160")
resource("temres161")
true
""
"temres32"
7
"p"
stderr:
(empty)
wasmtime on the exact same file: rc=1
"resinst0"
"resinst0"
"foo"
true
true
"temres132"
resource("temres26")
([resource("temres28")], "foo")
true
resource("temres160")
resource("temres161")
true
--- stderr ---
Error: failed to run main module `/Users/myuser/WASM/myProject/Wasm_component_testing/mycode/execute/reportrepo/G051-wit-bindgen-cpp-returns-empty-string-instead-of-original-value/composed.wasm`
Caused by:
0: failed to invoke `run` function
1: error while executing at wasm backtrace:
0: 0x5fe - <unknown>!<wasm function 17>
1: 0xa18f9 - wit-component:shim!indirect-mydefined:package3hl16smu1p/itf-n3bcdaqpyw-f-ywm7quh
2: 0x64eca - consumer.wasm!mydefined_package3hl16smu1p_itf_n3bcdaqpyw_f_ywm7quh
3: 0x642eb - consumer.wasm!exports_wasi_cli_run_run
4: 0x64fd1 - consumer.wasm!__wasm_export_exports_wasi_cli_run_run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
2: unknown handle index 521124
- 主要语言
- Rust
- 星标
- 1.5k
- 派生
- 306
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 21
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bytecodealliance/wit-bindgen 的其他 Issue
-
gen-rust
难度 4/5 3-5 天 新手友好度 25/100
bytecodealliance/wit-bindgen#1791 ·
维护者通常 1 天内回复
-
gen-rust
难度 4/5 3-5 天 新手友好度 22/100
bytecodealliance/wit-bindgen#1790 ·
维护者通常 1 天内回复
-
gen-rust
难度 3/5 半天 新手友好度 55/100
bytecodealliance/wit-bindgen#1787 ·
维护者通常 1 天内回复
-
gen-c#
难度 4/5 3-5 天 新手友好度 22/100
bytecodealliance/wit-bindgen#1759 ·
维护者通常 1 天内回复
-
Async exports never free the block of indirect parameters可能已有人在做 @Aditya1404Sal 于 37 天前认领。 未关闭async
难度 4/5 3-5 天 新手友好度 30/100
bytecodealliance/wit-bindgen#1757 ·
维护者通常 1 天内回复
查看 bytecodealliance/wit-bindgen 的全部 Issue
相似的 Issue
-
lane:collections todo:ticket
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 3 天内回复
-
bugfix
难度 2/5 1-3 小时 新手友好度 72/100
storytold/designcraft#3662 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue tooling
难度 2/5 1-3 小时 新手友好度 78/100
Nixitov/Riptide-Native#521 ·
维护者通常 1 天内回复