better error when native code tries to execute Rust function
This commit is contained in:
parent
fe91820130
commit
2feb8bba40
1 changed files with 12 additions and 1 deletions
|
|
@ -530,7 +530,18 @@ fn handle_segfault(
|
|||
// Don't use wait_for_signal here since 1 instruction doesn't give room
|
||||
// for any uncertainty + we don't want it `cont()`ing randomly by accident
|
||||
// Also, don't let it continue with unprotected memory if something errors!
|
||||
let _ = wait::waitid(wait::Id::Pid(pid), WAIT_FLAGS).map_err(|_| ExecEnd(None))?;
|
||||
let stat = wait::waitid(wait::Id::Pid(pid), WAIT_FLAGS).map_err(|_| ExecEnd(None))?;
|
||||
match stat {
|
||||
wait::WaitStatus::Signaled(_, s, _)
|
||||
| wait::WaitStatus::Stopped(_, s)
|
||||
| wait::WaitStatus::PtraceEvent(_, s, _) =>
|
||||
assert!(
|
||||
!matches!(s, signal::SIGSEGV),
|
||||
"native code segfaulted when re-trying memory access\n\
|
||||
is the native code trying to call a Rust function?"
|
||||
),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
// Zero out again to be safe
|
||||
for a in (ch_stack..ch_stack.strict_add(CALLBACK_STACK_SIZE)).step_by(ARCH_WORD_SIZE) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue