Merge pull request #2615 from alexcrichton/precise-pc-trap

Only handle signals at pcs with trap information
This commit is contained in:
Chris Fallin
2021-01-28 09:19:30 -08:00
committed by GitHub
2 changed files with 7 additions and 6 deletions

View File

@@ -432,7 +432,7 @@ pub unsafe trait TrapInfo {
/// Returns whether the given program counter lies within wasm code, /// Returns whether the given program counter lies within wasm code,
/// indicating whether we should handle a trap or not. /// indicating whether we should handle a trap or not.
fn is_wasm_code(&self, pc: usize) -> bool; fn is_wasm_trap(&self, pc: usize) -> bool;
/// Uses `call` to call a custom signal handler, if one is specified. /// Uses `call` to call a custom signal handler, if one is specified.
/// ///
@@ -635,7 +635,7 @@ impl<'a> CallThreadState<'a> {
} }
// If this fault wasn't in wasm code, then it's not our problem // If this fault wasn't in wasm code, then it's not our problem
if !self.trap_info.is_wasm_code(pc as usize) { if !self.trap_info.is_wasm_trap(pc as usize) {
return ptr::null(); return ptr::null();
} }

View File

@@ -191,8 +191,9 @@ impl Store {
None => return, None => return,
}; };
// Only register this module if it hasn't already been registered. // Only register this module if it hasn't already been registered.
if !self.is_wasm_code(first_pc) { let mut info = self.inner.frame_info.borrow_mut();
self.inner.frame_info.borrow_mut().register(module); if !info.contains_pc(first_pc) {
info.register(module);
} }
} }
@@ -400,8 +401,8 @@ unsafe impl TrapInfo for Store {
self self
} }
fn is_wasm_code(&self, addr: usize) -> bool { fn is_wasm_trap(&self, addr: usize) -> bool {
self.frame_info().borrow().contains_pc(addr) self.frame_info().borrow().lookup_trap_info(addr).is_some()
} }
fn custom_signal_handler(&self, call: &dyn Fn(&SignalHandler) -> bool) -> bool { fn custom_signal_handler(&self, call: &dyn Fn(&SignalHandler) -> bool) -> bool {