@@ -43,12 +43,6 @@ use crate::{inputs::Input, observers::ObserversTuple, state::HasCurrentTestcase}
4343/// The inmem executor's handlers.
4444#[ expect( missing_debug_implementations) ]
4545pub struct InProcessHooks < I , S > {
46- /// On crash C function pointer
47- #[ cfg( feature = "std" ) ]
48- pub crash_handler : * const c_void ,
49- /// On timeout C function pointer
50- #[ cfg( feature = "std" ) ]
51- pub timeout_handler : * const c_void ,
5246 /// `TImer` struct
5347 #[ cfg( feature = "std" ) ]
5448 pub timer : TimerStruct ,
@@ -196,20 +190,12 @@ impl<I, S> ExecutorHook<I, S> for InProcessHooks<I, S> {
196190 fn init ( & mut self , _state : & mut S ) { }
197191 /// Call before running a target.
198192 fn pre_exec ( & mut self , _state : & mut S , _input : & I ) {
199- #[ cfg( feature = "std" ) ]
200- unsafe {
201- let data = & raw mut GLOBAL_STATE ;
202- ( * data) . crash_handler = self . crash_handler ;
203- ( * data) . timeout_handler = self . timeout_handler ;
204- }
205-
206193 #[ cfg( all( feature = "std" , not( all( miri, target_vendor = "apple" ) ) ) ) ]
207194 self . timer_mut ( ) . set_timer ( ) ;
208195 }
209196
210197 /// Call after running a target.
211198 fn post_exec ( & mut self , _state : & mut S , _input : & I ) {
212- // timeout stuff
213199 // # Safety
214200 // We're calling this only once per execution, in a single thread.
215201 #[ cfg( all( feature = "std" , not( all( miri, target_vendor = "apple" ) ) ) ) ]
@@ -247,15 +233,19 @@ impl<I, S> InProcessHooks<I, S> {
247233 unsafe {
248234 setup_signal_handler ( data) ?;
249235 }
236+
237+ #[ cfg( feature = "std" ) ]
238+ unsafe {
239+ let data = & raw mut GLOBAL_STATE ;
240+ ( * data) . crash_handler =
241+ unix_signal_handler:: inproc_crash_handler :: < E , EM , I , OF , S , Z > as * const c_void ;
242+ ( * data) . timeout_handler =
243+ unix_signal_handler:: inproc_timeout_handler :: < E , EM , I , OF , S , Z > as * const _ ;
244+ }
245+
250246 compiler_fence ( Ordering :: SeqCst ) ;
251247 Ok ( Self {
252248 #[ cfg( feature = "std" ) ]
253- crash_handler : unix_signal_handler:: inproc_crash_handler :: < E , EM , I , OF , S , Z >
254- as * const c_void ,
255- #[ cfg( feature = "std" ) ]
256- timeout_handler : unix_signal_handler:: inproc_timeout_handler :: < E , EM , I , OF , S , Z >
257- as * const _ ,
258- #[ cfg( feature = "std" ) ]
259249 timer : TimerStruct :: new ( exec_tmout) ,
260250 phantom : PhantomData ,
261251 } )
@@ -288,7 +278,7 @@ impl<I, S> InProcessHooks<I, S> {
288278 > ( ) ;
289279 setup_exception_handler ( data) ?;
290280 compiler_fence ( Ordering :: SeqCst ) ;
291- let crash_handler =
281+ ( * data ) . crash_handler =
292282 crate :: executors:: hooks:: windows:: windows_exception_handler:: inproc_crash_handler :: <
293283 E ,
294284 EM ,
@@ -306,10 +296,9 @@ impl<I, S> InProcessHooks<I, S> {
306296 S ,
307297 Z ,
308298 > as * const c_void ;
299+ ( * data) . timeout_handler = timeout_handler;
309300 let timer = TimerStruct :: new ( exec_tmout, timeout_handler) ;
310301 ret = Ok ( Self {
311- crash_handler,
312- timeout_handler,
313302 timer,
314303 phantom : PhantomData ,
315304 } ) ;
@@ -347,10 +336,6 @@ impl<I, S> InProcessHooks<I, S> {
347336 #[ cfg( not( windows) ) ]
348337 pub fn nop ( ) -> Self {
349338 Self {
350- #[ cfg( feature = "std" ) ]
351- crash_handler : ptr:: null ( ) ,
352- #[ cfg( feature = "std" ) ]
353- timeout_handler : ptr:: null ( ) ,
354339 #[ cfg( feature = "std" ) ]
355340 timer : TimerStruct :: new ( Duration :: from_millis ( 5000 ) ) ,
356341 phantom : PhantomData ,
@@ -374,10 +359,10 @@ pub struct InProcessExecutorHandlerData {
374359
375360 /// The timeout handler
376361 #[ cfg( feature = "std" ) ]
377- pub ( crate ) crash_handler : * const c_void ,
362+ pub crash_handler : * const c_void ,
378363 /// The timeout handler
379364 #[ cfg( feature = "std" ) ]
380- pub ( crate ) timeout_handler : * const c_void ,
365+ pub timeout_handler : * const c_void ,
381366
382367 #[ cfg( all( windows, feature = "std" ) ) ]
383368 pub ( crate ) ptp_timer : Option < PTP_TIMER > ,
@@ -501,7 +486,7 @@ impl InProcessExecutorHandlerData {
501486}
502487
503488/// Exception handling needs some nasty unsafe.
504- pub ( crate ) static mut GLOBAL_STATE : InProcessExecutorHandlerData = InProcessExecutorHandlerData {
489+ pub static mut GLOBAL_STATE : InProcessExecutorHandlerData = InProcessExecutorHandlerData {
505490 // The state ptr for signal handling
506491 state_ptr : null_mut ( ) ,
507492 // The event manager ptr for signal handling
0 commit comments