@@ -856,7 +856,7 @@ namespace Js
856856 {
857857 faultInjectionDebug = true ;
858858 }
859- if (globalFlags.FaultInjection >= 0 && ! IsDebuggerPresent () )
859+ if (globalFlags.FaultInjection >= 0 )
860860 {
861861 // initialize symbol system here instead of inside the exception filter
862862 // because some hard stack overflow can happen in SymInitialize
@@ -1385,24 +1385,40 @@ namespace Js
13851385 static volatile bool inExceptionHandler = false ;
13861386 LONG WINAPI FaultInjection::FaultInjectionExceptionFilter (_In_ struct _EXCEPTION_POINTERS *ExceptionInfo)
13871387 {
1388+ if (inExceptionHandler)
1389+ {
1390+ // re-entering, this can happen if RemoveExceptionFilters() failed because of stack overflow
1391+ // Let it crash and the postmortem debugger can catch it.
1392+ DebugBreak ();
1393+ }
1394+
1395+ inExceptionHandler = true ;
1396+
13881397 RemoveExceptionFilters ();
1398+
13891399 // for debugging, can't hit here in windbg because of using vectored exception handling
13901400 if (faultInjectionDebug)
13911401 {
13921402 DebugBreak ();
13931403 }
13941404
1395- if (inExceptionHandler)
1405+ if (ExceptionInfo-> ExceptionRecord -> ExceptionCode == STATUS_STACK_OVERFLOW) // hard stack overflow
13961406 {
1397- // Let it crash and the postmorterm debugger can catch it.
1398- return EXCEPTION_CONTINUE_EXECUTION;
1407+ DebugBreak (); // let the postmortem debugger to create the dump, make sure they are filing bug with same bucket
1408+ }
1409+
1410+ __try
1411+ {
1412+ // sometimes the OS is really low memory and can't commit page for stack expanding
1413+ // even stack is not deep yet
1414+ FaultInjection::Global.FaultInjectionAnalyzeException (ExceptionInfo);
1415+ }
1416+ __except (EXCEPTION_EXECUTE_HANDLER)
1417+ {
1418+ DebugBreak ();
13991419 }
1420+ inExceptionHandler = false ;
14001421
1401- struct AutoValue {
1402- AutoValue () { inExceptionHandler = true ; }
1403- ~AutoValue () { inExceptionHandler = false ; }
1404- } autoVal;
1405- FaultInjection::Global.FaultInjectionAnalyzeException (ExceptionInfo);
14061422 return EXCEPTION_EXECUTE_HANDLER;
14071423 }
14081424
0 commit comments