Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmtime: Refactor trap-handling #9087

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

jameysharp
Copy link
Contributor

This commit groups together the registers that have to be collected from a signal handler to correctly report a trap: namely, the program counter and frame pointer, as of the time that the trap occurred.

I also moved the call to set_jit_trap inside test_if_trap for every platform that uses both methods. Only the implementation for Mach ports still needs to call set_jit_trap because it doesn't use test_if_trap.

In addition I'm fixing an unrelated doc comment that I stumbled across while working on this.

This commit groups together the registers that have to be collected from
a signal handler to correctly report a trap: namely, the program counter
and frame pointer, as of the time that the trap occurred.

I also moved the call to set_jit_trap inside test_if_trap for every
platform that uses both methods. Only the implementation for Mach ports
still needs to call set_jit_trap because it doesn't use test_if_trap.

In addition I'm fixing an unrelated doc comment that I stumbled across
while working on this.
@jameysharp jameysharp requested a review from a team as a code owner August 7, 2024 20:42
@jameysharp jameysharp requested review from elliottt and removed request for a team August 7, 2024 20:42
@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Aug 7, 2024
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -496,17 +501,16 @@ impl CallThreadState {
#[cfg_attr(miri, allow(dead_code))] // miri doesn't handle traps yet
pub(crate) fn set_jit_trap(
&self,
pc: *const u8,
fp: usize,
TrapRegisters { pc, fp, .. }: TrapRegisters,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about removing the .. to require this match to be re-examined if the TrapRegisters type changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I absolutely agree it's worth thinking about. My next PR specifically will add a field to this struct 😆 but this function won't need to look at it. I think it actually makes sense when pattern matching in this particular case to declare "I only care about these registers" even if more get collected later: these two are the ones we need for a backtrace or coredump.

@jameysharp jameysharp added this pull request to the merge queue Aug 7, 2024
Merged via the queue into bytecodealliance:main with commit 895180d Aug 7, 2024
37 checks passed
@jameysharp jameysharp deleted the trap-regs branch August 7, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants