Skip to content

Commit 2b31135

Browse files
authored
Fix reading registers on aarch64 FreeBSD (#13036)
The previous iteration of the code had a typo using `mcontext_t` instead of `ucontext_t` as the input pointer.
1 parent 3e724d7 commit 2b31135

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

crates/wasmtime/src/runtime/vm/sys/unix/signals.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ unsafe fn get_trap_registers(cx: *mut libc::c_void, _signum: libc::c_int) -> Tra
308308
fp: cx.uc_mcontext.__gregs[libc::REG_S0] as usize,
309309
}
310310
} else if #[cfg(all(target_os = "freebsd", target_arch = "aarch64"))] {
311-
let cx = unsafe { &*(cx as *const libc::mcontext_t) };
311+
let cx = unsafe { &*(cx as *const libc::ucontext_t) };
312312
TrapRegisters {
313-
pc: cx.mc_gpregs.gp_elr as usize,
314-
fp: cx.mc_gpregs.gp_x[29] as usize,
313+
pc: cx.uc_mcontext.mc_gpregs.gp_elr as usize,
314+
fp: cx.uc_mcontext.mc_gpregs.gp_x[29] as usize,
315315
}
316316
} else if #[cfg(all(target_os = "openbsd", target_arch = "x86_64"))] {
317317
let cx = unsafe { &*(cx as *const libc::ucontext_t) };
@@ -384,12 +384,12 @@ unsafe fn store_handler_in_ucontext(cx: *mut libc::c_void, handler: &Handler) {
384384
cx.uc_mcontext.mc_rax = 0;
385385
cx.uc_mcontext.mc_rdx = 0;
386386
} else if #[cfg(all(target_os = "freebsd", target_arch = "aarch64"))] {
387-
let cx = unsafe { cx.cast::<libc::mcontext_t>().as_mut().unwrap() };
388-
cx.mc_gpregs.gp_elr = handler.pc as _;
389-
cx.mc_gpregs.gp_sp = handler.sp as _;
390-
cx.mc_gpregs.gp_x[29] = handler.fp as _;
391-
cx.mc_gpregs.gp_x[0] = 0;
392-
cx.mc_gpregs.gp_x[1] = 0;
387+
let cx = unsafe { cx.cast::<libc::ucontext_t>().as_mut().unwrap() };
388+
cx.uc_mcontext.mc_gpregs.gp_elr = handler.pc as _;
389+
cx.uc_mcontext.mc_gpregs.gp_sp = handler.sp as _;
390+
cx.uc_mcontext.mc_gpregs.gp_x[29] = handler.fp as _;
391+
cx.uc_mcontext.mc_gpregs.gp_x[0] = 0;
392+
cx.uc_mcontext.mc_gpregs.gp_x[1] = 0;
393393
} else if #[cfg(all(target_os = "openbsd", target_arch = "x86_64"))] {
394394
let cx = unsafe { cx.cast::<libc::ucontext_t>().as_mut().unwrap() };
395395
cx.sc_rip = handler.pc as _;

0 commit comments

Comments
 (0)