Repository navigation
rust: preserve WASIp3 TLS for no-std task context - #1745
Merged
alexcrichton merged 2 commits intoOct 12, 2026
Merged
Conversation
The prebuilt task-context helper was compiled with -mcpu=mvp, which lowers its _Thread_local storage to a plain global. Overlapping async exports on WASIp3 then share the same task state and panic in start_task. Keep wasip3_task_set in the MVP archive used by every wasm32 target. Move the versioned context accessors into a separate archive compiled for wasm32-wasip3 and link it only for that target. Regenerate the C, object, and archive files and check the TLS-base import during rebuilds. Validation: - Stock nightly-2026-10-12 and Wasmtime 47.0.2: the unpatched HTTP handler returns 20/20 concurrent 500s; the fix returns 20/20 200s. - Rust 1.99.0 builds binaries and cdylibs for WASIp1, WASIp2, and wasm32-unknown-unknown without introducing TLS-base imports. - WASIp1/WASIp2 binaries and the unknown-target probe run successfully; native unit tests and the generated doctest pass. - SDK 34 and wasm-tools 1.258.0 regenerate artifacts identically on macOS arm64. Reintroducing the MVP flag makes the rebuild guard fail. - cargo fmt --all --check and git diff --check pass.
alexcrichton
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overlapping async exports on
wasm32-wasip3can panic whenwit-bindgen/stdis disabled. The existing C fallback declarestask_contextas_Thread_local, but its prebuilt object is compiled for the SDK’s default WASIp1 target with-mcpu=mvp. This produces a shared global, so a second export task sees the suspended task’s state and fails the assertion in start_task.This was found while testing a standard-library-using HTTP handler with wasip3 0.9.0, whose dependency configuration leaves wit-bindgen/std disabled. A second export starting before the first completes sees the first task’s state and fails the assertion in
start_task.This was found while testing concurrent requests to an HTTP handler built with Rust’s standard library and
wasip3 0.9.0, whose dependency configuration leaveswit-bindgen/stddisabled. The resulting panics cause the server to return HTTP 500 responses.