Skip to content

save and restore next_switch_item for sync-to-sync calls - #14624

Merged
dicej merged 3 commits into
bytecodealliance:mainfrom
dicej:fix-14562
Oct 9, 2026
Merged

dicej merged 3 commits into
bytecodealliance:mainfrom
dicej:fix-14562

Conversation

@dicej

@dicej dicej commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

We were doing this correctly for other types of calls, but somehow never thought of or tested for sync-to-sync calls 🤦.

Since we're not switching fibers in this case, we need to use a Vec as a stack instead of the call stack, which is slightly annoying, but not a big deal.

Fixes #14562

We were doing this correctly for other types of calls, but somehow never thought
of or tested for sync-to-sync calls 🤦.

Since we're not switching fibers in this case, we need to use a `Vec` as a stack
instead of the call stack, which is slightly annoying, but not a big deal.

Fixes bytecodealliance#14562

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
@dicej
dicej requested a review from a team as a code owner October 9, 2026 15:49
@dicej
dicej requested review from alexcrichton and cfallin and removed request for a team and cfallin October 9, 2026 15:49

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind updating assert_concurrent_state_empty to check this field as well?

@dicej
dicej enabled auto-merge October 9, 2026 16:56
@dicej
dicej disabled auto-merge October 9, 2026 17:04
@dicej
dicej disabled auto-merge October 9, 2026 17:04
@dicej
dicej enabled auto-merge October 9, 2026 17:07
@dicej
dicej added this pull request to the merge queue Oct 9, 2026
Merged via the queue into bytecodealliance:main with commit d6af75d Oct 9, 2026
53 checks passed
@dicej
dicej deleted the fix-14562 branch October 9, 2026 17:39
alexcrichton added a commit that referenced this pull request Oct 9, 2026
* [50.0.x] save and restore `next_switch_item` for sync-to-sync calls

We were doing this correctly for other types of calls, but somehow never thought
of or tested for sync-to-sync calls 🤦.

Since we're not switching fibers in this case, we need to use a `Vec` as a stack
instead of the call stack, which is slightly annoying, but not a big deal.

Fixes #14562

Co-authored-by: Alex Crichton <alex@alexcrichton.com>

add check for `saved_next_switch_items` to `assert_concurrent_state_empty`

add test from #14618, which is also addressed by the fix for #14562

* [50.0.x] Route more component adapters to the host (#14574)

Prior to this commit adapters were fully compiled inline for sync<->sync
adapters, but only if the lift/lowers were sync. This was incorrect when
the intermediate function type was `async`, however, in a number of
ways. This bug led to a number of `bail_bug!`s and incorrect execution
when using the FACT-compiled adapter. The fix in this commit is to route
async-typed adapted functions through the host like other async items.
This additionally refactors things internally with less duplication,
for example `sync_start` and `async_start` are now `start_call`, and the
various cases in the trampoline compiler are consolidated into one.

This changes preexisting behavior of one test, with the comment of the
test adjusted from explaining the prior behavior to explaining the
current behavior.

---------

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
Byte-Naut pushed a commit to Byte-Naut/wasmtime that referenced this pull request Oct 10, 2026
)

This commit follows up with some more regression tests from bytecodealliance#14624 which
are from other bugs but fixed by the same PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hitting bail_bug! when synchronous component model tasks exit

2 participants