Check PAL_VirtualUnwind failure during GC (dotnet/coreclr#6598)
authorJonghyun Park <parjong@gmail.com>
Mon, 8 Aug 2016 01:35:54 +0000 (10:35 +0900)
committerJan Kotas <jkotas@microsoft.com>
Mon, 8 Aug 2016 01:35:54 +0000 (18:35 -0700)
As discussed in dotnet/coreclr#6525, PAL_VirtualUnwind sometimes fails during GC.

This GC failure leads to very unpredicatble behavior (which is very hard to
analyze).

This commit tries to stop the execution at the point where error
happens.

Commit migrated from https://github.com/dotnet/coreclr/commit/deb00ad58acf627763b6c0a7833fa789e3bb1cd0

src/coreclr/src/vm/amd64/gmsamd64.cpp
src/coreclr/src/vm/arm/stubs.cpp
src/coreclr/src/vm/arm64/stubs.cpp

index b6e596e..29d7872 100644 (file)
@@ -62,7 +62,12 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
             DacError(hr);
         }
 #else
-        PAL_VirtualUnwind(&ctx, &nonVolRegPtrs);
+        BOOL success = PAL_VirtualUnwind(&ctx, &nonVolRegPtrs);
+        if (!success)
+        {
+            _ASSERTE(!"unwindLazyState: Unwinding failed");
+            EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
+        }
 #endif  // DACCESS_COMPILE    
 
         pvControlPc = GetIP(&ctx);
index 9868cb6..0b069da 100644 (file)
@@ -544,7 +544,12 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
             DacError(hr);
         }
 #else // DACCESS_COMPILE
-        PAL_VirtualUnwind(&ctx, &nonVolRegPtrs);
+        BOOL success = PAL_VirtualUnwind(&ctx, &nonVolRegPtrs);
+        if (!success)
+        {
+            _ASSERTE(!"unwindLazyState: Unwinding failed");
+            EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
+        }
 #endif // DACCESS_COMPILE
         pvControlPc = GetIP(&ctx);
 #endif // !FEATURE_PAL
index 7db8a31..2b239cd 100644 (file)
@@ -330,7 +330,12 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
             DacError(hr);
         }
 #else // DACCESS_COMPILE
-        PAL_VirtualUnwind(&context, &nonVolContextPtrs);  
+        BOOL success = PAL_VirtualUnwind(&ctx, &nonVolContextPtrs);
+        if (!success)
+        {
+            _ASSERTE(!"unwindLazyState: Unwinding failed");
+            EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
+        }
 #endif // DACCESS_COMPILE
         pvControlPc = GetIP(&context);
 #endif // !FEATURE_PAL