Stream: git-wasmtime

Topic: wasmtime / PR #14398 [stack-switching] Interop with ASan


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

dhil opened PR #14398 from dhil:stack-switching-asan to bytecodealliance:main:

This patch adds facilities for instrumenting continuation stack switches with ASan's fiber switch hooks. The implementation is nearly zero-cost for non-ASan builds save for two new
VMCommonStackInformation fields used to track stack bounds and fake-stack state. I will consider wasy to eliminate this overheads once I start working on optimising stack switching.

prtest:full

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

dhil requested cfallin for a review on PR #14398.

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

dhil requested wasmtime-core-reviewers for a review on PR #14398.

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

dhil requested wasmtime-compiler-reviewers for a review on PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 15:15):

dhil edited PR #14398:

This patch adds facilities for instrumenting continuation stack switches with ASan's fiber switch hooks. The implementation is nearly zero-cost for non-ASan builds save for two new
VMCommonStackInformation fields used to track stack bounds and fake-stack state. I will consider wasy to eliminate this overheads once I start working on optimising stack switching.

prtest:full

Resolves #14222

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 15:58):

dhil updated PR #14398.

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

dhil updated PR #14398.

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

fitzgen added the label wasm-proposal:stack-switching on PR #14398.

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

dhil updated PR #14398.

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

dhil edited PR #14398:

This patch adds facilities for instrumenting continuation stack switches with ASan's fiber switch hooks. The implementation is nearly zero-cost for non-ASan builds save for two new
VMCommonStackInformation fields used to track stack bounds and fake-stack state. I will consider ways to eliminate this overheads once I start working on optimising stack switching.

prtest:full

Resolves #14222

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 17:44):

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

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 17:44):

github-actions[bot] added the label wasmtime:config on PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:thumbs_up: cfallin submitted PR review:

This looks reasonable overall -- thanks! A few comments below but nothing major.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:speech_balloon: cfallin created PR review comment:

Do we want to try to share one (lazily-created) stack slot for all stack switch ops in a function, if there is more than one? As-is this will create a stackframe size linear in the number of switch ops, which might be suboptimal for some kinds of continuation usage (e.g. frequent async yield points or ...). We could stash an Option<StackSlot> on the env for example.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:speech_balloon: cfallin created PR review comment:

Can we add a comment here about this arithmetic (that, I think, we are excluding the guard page from the stack region that we tell ASan about, because that doesn't work / we aren't supposed to be accessing it / ...)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:speech_balloon: cfallin created PR review comment:

We should probably note why this is a dynamic config option rather than a static cfg!(asan) -- this is to support cross-compilation (compiler build doesn't have asan but runtime does), right?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:speech_balloon: cfallin created PR review comment:

Rather than fine-grained cfg(asan) here, perhaps two submodules, asan::enabled and asan::disabled, each conditionally gated, and with pub use re-exports here? (Follows the pattern we have elsewhere and makes code a little easier to read)

Or if the defs aren't needed in the disabled-case, then let's just cfg-gate the whole asan module.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:27):

:speech_balloon: cfallin created PR review comment:

Rather than inline cfg'd blocks, perhaps a helper function with two cfg-gated functions? A little easier to read at least.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 18:49):

github-actions[bot] commented on PR #14398:

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html


<details>

To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.

To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.

Learn more.

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 14:41):

:memo: dhil submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 14:41):

:speech_balloon: dhil created PR review comment:

I keep making this mistake -- yes! I think I will do a slightly more general thing here and package up the various stack_switching_ support fields into a coherent structure, rather than keep appending inline on FuncEnvironment.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 14:47):

:memo: dhil submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 14:47):

:speech_balloon: dhil created PR review comment:

Yes, to ensure that the compiled artifact is compatible with the runtime. I will reword it.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:00):

:memo: dhil submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:00):

:speech_balloon: dhil created PR review comment:

Yes correct, ASan fiber switch needs the bounds of the readable and writeable stack region, which excludes the guard page. I will add a comment.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:02):

:memo: dhil submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:02):

:speech_balloon: dhil created PR review comment:

Good idea, thanks! I've added a enabled and disabled now (I'll commit it in a moment).

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:04):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:20):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:23):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:45):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 16:09):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 18:40):

:speech_balloon: cfallin created PR review comment:

We can probably fold these parameters into env.get_or_create_asan_fake_stack_slot() (pointer_bytes also comes from env)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 18:40):

:thumbs_up: cfallin submitted PR review:

Thanks! Just one little nit but otherwise happy to merge.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 11:23):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 11:23):

dhil updated PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 11:25):

:memo: dhil submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 11:25):

:speech_balloon: dhil created PR review comment:

Yes good point, thanks!

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

cfallin added PR #14398 [stack-switching] Interop with ASan to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 17:05):

:check: cfallin merged PR #14398.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 26 2026 at 17:05):

cfallin removed PR #14398 [stack-switching] Interop with ASan from the merge queue.


Last updated: Oct 11 2026 at 02:20 UTC