fix: guard asyncify_stop_unwind() for async web API import unwinds (i…#25
Open
itsbryanman wants to merge 1 commit into
Open
fix: guard asyncify_stop_unwind() for async web API import unwinds (i…#25itsbryanman wants to merge 1 commit into
itsbryanman wants to merge 1 commit into
Conversation
…ssue 6over3#7) Only call asyncify_stop_unwind() when pl_asyncify_unwind_buf is non-NULL, which indicates a C-level (setjmp/longjmp/scan) unwind. When an asyncify import like call_host_function triggers an unwind, the transform bypasses our macro so pl_asyncify_unwind_buf stays NULL. Calling asyncify_stop_unwind() in that case clears __asyncify_state from 1 (UNWINDING) to 0 before the export returns to JS, hiding the pending async op from asyncify-wasm. Fixes 6over3#7
5182442 to
b5d6582
Compare
Author
|
/claim #7 |
Author
|
Hey, just checking in on this one. The branch is still up to date with main and the fix is ready for review. Happy to add tests or a CHANGELOG entry if that would help move this forward. Let me know! |
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.
Fix: guard asyncify_stop_unwind() for async web API import unwinds (issue #7)
Root Cause
The runtime loop in
stubs/runtime.cunconditionally calledasyncify_stop_unwind()after every return frommain(). When an asyncify import (call_host_function) triggered an unwind, this cleared__asyncify_statefrom 1 (UNWINDING) to 0 before the export returned to JS. The asyncify-wasm host then saw state 0, concluded execution finished normally, and never awaited the pending Promise — the async call was silently dropped.The Fix
pl_asyncify_unwind_bufis set by zeroperl's ownasyncify_start_unwind()macro for C-level unwinds (setjmp/longjmp/scan), but NOT by the asyncify transform's internal import handling. This makes it a clean discriminator:pl_asyncify_unwind_buf != NULL→ C-level unwind → safe to callasyncify_stop_unwind()and dispatchpl_asyncify_unwind_buf == NULL→ normal exit OR async import unwind → do NOT clear__asyncify_state, let asyncify-wasm handle itOnly
stubs/runtime.cneeded to change. No new files, no changes tomachine.c,machine.h, orzeroperl.c.Fixes #7
/claim