@@ -257,36 +257,16 @@ private void ExecuteAccessViolation()
257257 /// </remarks>
258258 private void ExecuteNativeCrash ( )
259259 {
260- _logger . LogCritical ( "Triggering native crash - attempting multiple methods !" ) ;
260+ _logger . LogCritical ( "Triggering native crash via RaiseException (FAIL_FAST_EXCEPTION) !" ) ;
261261
262- // Method 1: RtlFailFast - should bypass all handlers
263- try
264- {
265- _logger . LogCritical ( "Attempting RtlFailFast..." ) ;
266- const uint FAST_FAIL_FATAL_APP_EXIT = 7 ;
267- RtlFailFast ( FAST_FAIL_FATAL_APP_EXIT ) ;
268- }
269- catch
270- {
271- _logger . LogWarning ( "RtlFailFast was caught (unexpected!)" ) ;
272- }
273-
274- // Method 2: Direct null pointer dereference via unsafe code
275- _logger . LogCritical ( "RtlFailFast didn't crash, trying unsafe null dereference..." ) ;
276- unsafe
277- {
278- int * nullPtr = ( int * ) 0 ;
279- * nullPtr = 42 ; // This WILL crash
280- }
281-
282- // Method 3: If somehow we're still alive, use FailFast
283- _logger . LogCritical ( "Unsafe code didn't crash?! Using Environment.FailFast..." ) ;
284- Environment . FailFast ( "NativeCrash fallback: RtlFailFast and unsafe null dereference both failed!" ) ;
262+ // Use RaiseException with FAIL_FAST_EXCEPTION code (0xC0000409)
263+ // This is the same exception code used by __fastfail and is reliably captured
264+ // by Windows Error Reporting and Azure Crash Monitoring
265+ const uint STATUS_STACK_BUFFER_OVERRUN = 0xC0000409 ; // __fastfail exception code
266+ const uint EXCEPTION_NONCONTINUABLE = 0x1 ;
267+ RaiseException ( STATUS_STACK_BUFFER_OVERRUN , EXCEPTION_NONCONTINUABLE , 0 , IntPtr . Zero ) ;
285268 }
286269
287- [ DllImport ( "ntdll.dll" ) ]
288- private static extern void RtlFailFast ( uint Code ) ;
289-
290270 /// <summary>
291271 /// Allocates memory until the process runs out and crashes.
292272 /// </summary>
0 commit comments