alexcrichton opened PR #13306 from alexcrichton:exception-refactor to bytecodealliance:main:
This commit adjust the exception-handling logic within
traphandlers.rsto account for when embedders returnThrownExceptionwithout actually putting an exception within the store. This refactoring was done by removingTrapReason::Exceptionentirely and instead reusing theTrapReason::User(Error)variant for all exceptions plus some extra guards about doing exception-related things when the store is actually missing an exception.By preserving the error as-is this additionally keeps the original
Erroraround in case it had more context. For example embedders could returnThrownException.into()and then attach more context to the error, but all of the context would be lost internally within Wasmtime when the error was discarded in favor of theTrapReason::Exceptionvariant. Instead now the originalErroris preserved to retain all context if it ends up getting uncaught or threaded through.An additional fix here is that uncaught wasm-originating exceptions now execute the normal logic for "capture a stack trace". Previously the handling of
TrapReason::Exceptiondidn't account for this logic meaning that uncaught wasm exceptions would not report a backtrace.Closes #13304
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested fitzgen for a review on PR #13306.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13306.
alexcrichton updated PR #13306.
:thumbs_up: fitzgen submitted PR review:
Good catch!
alexcrichton updated PR #13306.
alexcrichton added PR #13306 Fix returning ThrownException alone to the merge queue.
github-actions[bot] added the label wasmtime:api on PR #13306.
github-merge-queue[bot] removed PR #13306 Fix returning ThrownException alone from the merge queue.
alexcrichton updated PR #13306.
alexcrichton has enabled auto merge for PR #13306.
alexcrichton commented on PR #13306:
I pushed up some relatively invasive refactors, but I'm about to delete much of this anyway in a subsequent PR so it should be pretty short-lived.
alexcrichton updated PR #13306.
alexcrichton added PR #13306 Fix returning ThrownException alone to the merge queue.
:check: alexcrichton merged PR #13306.
alexcrichton removed PR #13306 Fix returning ThrownException alone from the merge queue.
Last updated: Jun 01 2026 at 09:49 UTC