Stream: git-wasmtime

Topic: wasmtime / PR #14984 c-api: handle NULL arrays with a zer...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2026 at 14:39):

netliomax25-code opened PR #14984 from netliomax25-code:c-api-wasi-null-slices to bytecodealliance:main:

wasi_config_set_argv and wasi_config_set_env build their slices with std::slice::from_raw_parts directly on the caller's pointer and count. With a count of 0 and a NULL array this is undefined behavior in Rust, since from_raw_parts requires a non-null pointer even for an empty slice. The C++ wrapper hits it with WasiConfig::argv({}) or env({}), because data() of an empty std::vector is NULL, and a debug build of the C API aborts with:

unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null

The rest of the C API already goes through crate::slice_from_raw_parts, which returns an empty slice when the length is 0, so these three call sites now use it too. They were the only remaining direct slice::from_raw_parts calls on caller-provided pointers in crates/c-api/src.

I added a WasiConfig.EmptyArgvEnv test to crates/c-api/tests/wasi.cc. It aborts at wasi.rs:72 without the fix and passes with it, and the full C API test binary (147 tests, Debug, -DBUILD_TESTS=ON) passes on macOS aarch64.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2026 at 14:39):

netliomax25-code removed the review request for wasmtime-core-reviewers from PR #14984.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2026 at 14:39):

netliomax25-code requested wasmtime-core-reviewers for a review on PR #14984.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2026 at 14:39):

netliomax25-code requested dicej for a review on PR #14984.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 24 2026 at 16:46):

github-actions[bot] added the label wasmtime:c-api on PR #14984.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 26 2026 at 14:16):

:thumbs_up: dicej submitted PR review:

Thanks, @netliomax25-code!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 26 2026 at 14:16):

dicej added PR #14984 c-api: handle NULL arrays with a zero count in wasi_config_set_argv/env to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 26 2026 at 14:39):

:check: dicej merged PR #14984.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 26 2026 at 14:39):

dicej removed PR #14984 c-api: handle NULL arrays with a zero count in wasi_config_set_argv/env from the merge queue.


Last updated: Oct 31 2026 at 23:03 UTC