Stream: git-wasmtime

Topic: wasmtime / PR #12928 Update fibers to avoid no-return fun...


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

alexcrichton opened PR #12928 from alexcrichton:fiber-less-asan-false-positive to bytecodealliance:main:

This commit is aimed at fixing the ASAN false positives in #12899. Initially the fix there was to invoke some __asan_* intrinsics, and I ended up finding a sort of smaller set of __asan_* intrinsics to call as well. In the end what's happening though is that fibers, upon terminating, have a few frames of Rust code on the stack before switching off. To ASAN these frames never returned so when a stack is subsequently reused ASAN is tricked into thinking this is buffer overflow or use-after-free since it's stomping on frames that haven't returned.

The fix in this commit is to avoid this style of function which doesn't returns. Functions which don't return in Rust are easy to leak memory from and are a hazard from a safety perspective as well (e.g. it's unsafe to skip running destructors of stack variables). I feel we've had better success over time with "all Rust functions always return" and so what's what was applied here. Unlike #12899 or my thoughts on that PR this does not have any new __asan_* intrinsic calls. Instead what this does is it shuffles around responsibility for what exact piece of the infrastructure is responsible for what. Specifically fiber_start functions now actually return, meaning the wasmtime_fiber_start naked function actually resumes execution, unlike before. The wasmtime_fiber_start then delegates to wasmtime_fiber_switch immediately to perform the final switch.

Effectively there's now only two function frames that never return, and both of these frames are handwritten inline assembly. This means that ASAN gets to see that all normal functions return and updates all of its metadata accordingly. The end result is that the original issue from #12899 is fixed and this I feel is in general more robust as well.

One caveat is that the handwritten wasmtime_fiber_start assembly needs to invoke a sibling wasmtime_fiber_switch_ function. In lieu of trying to figure out how to get PIC-vs-not calls working (e.g. static calls) I've opted to use indirect function calls and pointers instead. This mirrors historical changes in our fiber implementation too.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

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

alexcrichton requested pchickey for a review on PR #12928.

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

alexcrichton requested wasmtime-core-reviewers for a review on PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 16:58):

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 17:35):

alexcrichton added PR #12928 Update fibers to avoid no-return functions to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 18:03):

github-merge-queue[bot] removed PR #12928 Update fibers to avoid no-return functions from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 18:19):

alexcrichton updated PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 18:19):

alexcrichton has enabled auto merge for PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 18:33):

alexcrichton added PR #12928 Update fibers to avoid no-return functions to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 18:57):

github-merge-queue[bot] removed PR #12928 Update fibers to avoid no-return functions from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 20:09):

alexcrichton updated PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 20:09):

alexcrichton has enabled auto merge for PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 20:22):

alexcrichton added PR #12928 Update fibers to avoid no-return functions to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 20:56):

alexcrichton merged PR #12928.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2026 at 20:56):

alexcrichton removed PR #12928 Update fibers to avoid no-return functions from the merge queue.


Last updated: Apr 12 2026 at 23:10 UTC