wasmtime: Fix resetting stack-walking registers when entering/exiting Wasm#6321
Conversation
bc28367 to
e4c1d36
Compare
|
Oh one thing I thought of this morning -- this means that the backtrace code is no longer guaranteed to walk the stack in-order of activations. I don't believe there's any issues with that, but it's worth being aware of. The reason for this is that while the activations are ordered when we walk each activation we walk its If you had A call B call A which trapped, then you'd get the first contiguous region in A but then when you walk over the Hm ok so now as I write this out, I think it means that |
|
I don't understand the issue you're raising, Alex, but my profiling work will produce misleading results if the subset of stack frames which are part of the user-selected modules are returned out of order. Should I be concerned about this? |
|
Sort of yes and sort of no. Within a single This is ok for For the profiler just added, however, it doesn't do any filtering, so it does mean that frames will be out of order since non-store-local frames are not filtered out. @fitzgen I'm actually going to bump this out of the queue now that I think on this more. I'm worried about the case where a module is instantiated in two stores and then the store are interleaved. All frames will symbolicate in either store but the stacks are going to be quite odd. I think we should actually explicitly update backtracing to take a |
|
The new profiler actually does filter to only frames from a specified set of modules, but your point still stands because it has the same problem that |
… Wasm Fixes a regression from bytecodealliance#6262, originally reported in bytecodealliance/wasmtime-dotnet#245 The issue was that we would enter Wasm and save the stack-walking registers but never clear them after Wasm returns. Then if a host-to-host call tried to capture a stack, we would mistakenly attempt to use those stale registers to start the stack walk. This mistake would be caught by an assertion, triggering a panic. This commit fixes the issue by managing the save/restore in the `CallThreadState` construction/drop, rather than in the old `set_prev` method. Co-Authored-By: Alex Crichton <alex@alexcrichton.com>
This way we can differentiate between the same module loaded in different stores and avoid leaking other stores' frames into our backtraces. Co-Authored-By: Jamey Sharp <jsharp@fastly.com>
e4c1d36 to
6927bbf
Compare
Subscribe to Label Actioncc @fitzgen, @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Fixes a regression from #6262, originally reported in bytecodealliance/wasmtime-dotnet#245
The issue was that we would enter Wasm and save the stack-walking registers but never clear them after Wasm returns. Then if a host-to-host call tried to capture a stack, we would mistakenly attempt to use those stale registers to start the stack walk. This mistake would be caught by an assertion, triggering a panic.
This commit fixes the issue by managing the save/restore in the
CallThreadStateconstruction/drop, rather than in the oldset_prevmethod.