alexcrichton opened PR #4325 from trap-backtrace-with-store
to main
:
Previous to this commit Wasmtime would use the
GlobalModuleRegistry
when learning information about a trap such as its trap code, the
symbols for each frame, etc. This has a downside though of holding a
global read-write lock for the duration of this operation which hinders
registration of new modules in parallel. In addition there was a fair
amount of internal duplication between this "global module registry" and
the store-local module registry. Finally relying on global state for
information like this gets a bit more brittle over time as it seems best
to scope global queries to precisely what's necessary rather than
holding extra information.With the refactoring in wasm backtraces done in #4183 it's now possible
to always have aStoreOpaque
reference when a backtrace is collected
for symbolication and otherwise Trap-identification purposes. This
commit adds aStoreOpaque
parameter to theTrap::from_runtime
constructor and then plumbs that everywhere. Note that while doing this
I changed the internaltraphandlers::lazy_per_thread_init
function to
no longer return aResult
and instead justpanic!
on Unix if memory
couldn't be allocated for a stack. This removed quite a lot of
error-handling code for a case that's expected to quite rarely happen.
If necessary in the future we can add a fallible initialization point
but this feels like a better default balance for the code here.With a
StoreOpaque
in use when a trap is being symbolicated that means
we have aModuleRegistry
which can be used for queries and such. This
meant that theGlobalModuleRegistry
state could largely be dismantled
and moved to per-Store
state (within theModuleRegistry
, mostly just
moving methods around).The final state is that the global rwlock is not exclusively scoped
around insertions/deletions/is_wasm_trap_pc
which is just a lookup and
atomic add. Otherwise symbolication for a backtrace exclusively uses
store-local state now (as intended).The original motivation for this commit was that frame information
lookup and pieces were looking to get somewhat complicated with the
addition of components which are a new vector of traps coming out of
Cranelift-generated code. My hope is that by having aStore
around for
more operations it's easier to plumb all this through.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton requested fitzgen for a review on PR #4325.
alexcrichton updated PR #4325 from trap-backtrace-with-store
to main
.
pchickey submitted PR review.
pchickey submitted PR review.
pchickey created PR review comment:
.expect("allocating memory map for altstack");
fitzgen submitted PR review.
alexcrichton updated PR #4325 from trap-backtrace-with-store
to main
.
alexcrichton merged PR #4325.
Last updated: Dec 23 2024 at 12:05 UTC