Support checking the execution limit exceeded error.

This commit is contained in:
losfair
2019-06-05 11:51:33 +08:00
parent 0867208e0c
commit f2d8aad73a
4 changed files with 17 additions and 6 deletions

View File

@ -128,11 +128,12 @@ pub fn call_protected<T>(f: impl FnOnce() -> T) -> Result<T, CallProtError> {
}
}
pub unsafe extern "C" fn throw() -> ! {
pub unsafe fn throw(payload: Box<dyn Any>) -> ! {
let jmp_buf = SETJMP_BUFFER.with(|buf| buf.get());
if *jmp_buf == [0; SETJMP_BUFFER_LEN] {
::std::process::abort();
}
TRAP_EARLY_DATA.with(|cell| cell.replace(Some(payload)));
longjmp(jmp_buf as *mut ::nix::libc::c_void, 0xffff);
}