Stream: git-wasmtime

Topic: wasmtime / PR #13306 Fix returning `ThrownException` alone


view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:27):

alexcrichton opened PR #13306 from alexcrichton:exception-refactor to bytecodealliance:main:

This commit adjust the exception-handling logic within traphandlers.rs to account for when embedders return ThrownException without actually putting an exception within the store. This refactoring was done by removing TrapReason::Exception entirely and instead reusing the TrapReason::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 Error around in case it had more context. For example embedders could return ThrownException.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 the TrapReason::Exception variant. Instead now the original Error is 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::Exception didn'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:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:27):

alexcrichton requested fitzgen for a review on PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:27):

alexcrichton requested wasmtime-core-reviewers for a review on PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:50):

alexcrichton updated PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:52):

:thumbs_up: fitzgen submitted PR review:

Good catch!

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 19:55):

alexcrichton updated PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 20:51):

alexcrichton added PR #13306 Fix returning ThrownException alone to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:05):

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

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:11):

github-merge-queue[bot] removed PR #13306 Fix returning ThrownException alone from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:18):

alexcrichton updated PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:18):

alexcrichton has enabled auto merge for PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:18):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:23):

alexcrichton updated PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 21:39):

alexcrichton added PR #13306 Fix returning ThrownException alone to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 22:04):

:check: alexcrichton merged PR #13306.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2026 at 22:04):

alexcrichton removed PR #13306 Fix returning ThrownException alone from the merge queue.


Last updated: Jun 01 2026 at 09:49 UTC