The registered signal handler can return two states: 1.ContinueType:Search Continue searching for the next registered signal handler.
2.ContinueType::Execution Continue to execute the instruction that caused the exception. If the exception is not handled on the handler chain (all return ContinueType:Search), the default handler will inject panic, and we can catch unwind. config.xml: `<HeapMaxSize>0x80000</HeapMaxSize>` sample code: ``` use std::alloc; use std::backtrace::{self, PrintFormat}; use std::panic; use std::vec::Vec; use sgx_signal::ContinueType; use sgx_signal::exception; use sgx_types::sgx_exception_info_t; #[no_mangle] pub extern "C" fn ecall_entry() { let _ = backtrace::enable_backtrace("enclave.signal.so", PrintFormat::Full); let handler = { move |_info: &mut sgx_exception_info_t| { ContinueType::Search } }; alloc::set_alloc_error_hook(|layout| { println!("memory allocation of {} bytes failed", layout.size()); unsafe { std::intrinsics::abort() }; }); let _h = exception::register_exception(true, handler); panic::catch_unwind(|| { test_alloc_memory() }).ok(); let mut success = vec![0_u8; 0x20000]; success[0] = 1; } #[no_mangle] #[inline(never)] fn test_alloc_memory() { let _failed = vec![0_u8; 0x100000]; } ``` @reuvenpo hope it can help you. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/apache/incubator-teaclave-sgx-sdk/issues/254#issuecomment-652804768