feat: support schedule_reinit() under panic=abort builds#5099
Merged
Conversation
d04d3cd to
cbdf659
Compare
hoodmane
reviewed
Apr 9, 2026
hoodmane
reviewed
Apr 9, 2026
hoodmane
reviewed
Apr 9, 2026
hoodmane
reviewed
Apr 9, 2026
hoodmane
approved these changes
Apr 9, 2026
hoodmane
left a comment
Contributor
There was a problem hiding this comment.
LGTM aside from a few suggestions.
0ecd8b4 to
cf1989e
Compare
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.
Summary
Previously
handler::schedule_reinit()was a no-op underpanic=abort. This extends it to work with both panic strategies.Under
panic=abortthere's no__instance_terminatedflag or wasm-level catch wrappers, so the full abort detection machinery doesn't apply. Butschedule_reinit()is independent of abort detection — it just sets a JS-side flag (__wbg_reinit_scheduled) that's checked before each export call. This PR adds that minimal path.#[cfg(panic = "unwind")]gate onschedule_reinit()so it calls__wbindgen_reinit()in all buildsgenerate_reinit_guard()— emits a simple__wbg_termination_guardthat only checks__wbg_reinit_scheduled(no try/catch, no__instance_terminated)maybe_wrap_try_catchintomaybe_wrap_export_callwith separatecheck_aborted/check_reinitflags — exports underpanic=abortget the guard prepended without try/catch wrapping__wbg_reset_stateto reset__wbg_reinit_scheduledin all builds (not just whenwrapped_js_tagis present)reinit_panic_abortintegration test: builds with-Cpanic=abort -Zbuild-std=std,panic_abort, verifies new instance creation, static reset, persistence without signal, and multiple reinit cycles