From 2f9b2794285138a92aab6dcb00302e6f0522e0c6 Mon Sep 17 00:00:00 2001 From: Max Ammann Date: Sat, 10 Dec 2022 01:29:27 +0100 Subject: [PATCH] [Windows] Handle crashes without exception (#912) * Handle that exception_pointers can be null * Fix formatting * windows: Handle crashes without exception --- libafl/src/executors/inprocess.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libafl/src/executors/inprocess.rs b/libafl/src/executors/inprocess.rs index ca5f4168ea..06fd88f9a1 100644 --- a/libafl/src/executors/inprocess.rs +++ b/libafl/src/executors/inprocess.rs @@ -1294,20 +1294,22 @@ mod windows_exception_handler { compiler_fence(Ordering::SeqCst); } - let code = ExceptionCode::try_from( - exception_pointers - .as_mut() - .unwrap() - .ExceptionRecord - .as_mut() - .unwrap() - .ExceptionCode - .0, - ) - .unwrap(); - #[cfg(feature = "std")] - eprintln!("Crashed with {}", code); + if let Some(exception_pointers) = exception_pointers.as_mut() { + let code = ExceptionCode::try_from( + exception_pointers + .ExceptionRecord + .as_mut() + .unwrap() + .ExceptionCode + .0, + ) + .unwrap(); + eprintln!("Crashed with {}", code); + } else { + eprintln!("Crashed without exception (probably due to SIGABRT)"); + }; + if data.current_input_ptr.is_null() { #[cfg(feature = "std")] {