[Local GC] Redirect fatal errors to the EE (dotnet/coreclr#10436)
authorSean Gillespie <sean@swgillespie.me>
Fri, 24 Mar 2017 01:40:56 +0000 (18:40 -0700)
committerGitHub <noreply@github.com>
Fri, 24 Mar 2017 01:40:56 +0000 (18:40 -0700)
* [Local GC] Redirect fatal errors to the EE

* Address code review feedback: don't fetch the IP when reporting a fatal error

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

src/coreclr/src/gc/env/gcenv.ee.h
src/coreclr/src/gc/gc.cpp
src/coreclr/src/gc/gcenv.ee.standalone.inl
src/coreclr/src/gc/gcinterface.ee.h
src/coreclr/src/gc/sample/gcenv.ee.cpp
src/coreclr/src/vm/gcenv.ee.cpp
src/coreclr/src/vm/gcenv.ee.h

index 9f7f266..689b1cc 100644 (file)
@@ -68,6 +68,8 @@ public:
     static void StompWriteBarrier(WriteBarrierParameters* args);
 
     static void EnableFinalization(bool foundFinalizers);
+
+    static void HandleFatalError(unsigned int exitCode);
 };
 
 #endif // __GCENV_EE_H__
index 1a5072e..a1a691e 100644 (file)
@@ -17496,7 +17496,7 @@ void gc_heap::enque_pinned_plug (uint8_t* plug,
             // risks. This happens very rarely and fixing it in the
             // way so that we can continue is a bit involved and will
             // not be done in Dev10.
-            EEPOLICY_HANDLE_FATAL_ERROR(CORINFO_EXCEPTION_GC);
+            GCToEEInterface::HandleFatalError(CORINFO_EXCEPTION_GC);
         }
     }
 
@@ -25002,7 +25002,7 @@ void gc_heap::gc_thread_stub (void* arg)
 #else
         STRESS_LOG0(LF_GC, LL_ALWAYS, "Thread::CommitThreadStack failed.");
         _ASSERTE(!"Thread::CommitThreadStack failed.");
-        EEPOLICY_HANDLE_FATAL_ERROR(COR_E_STACKOVERFLOW);
+        GCToEEInterface::HandleFatalError(COR_E_STACKOVERFLOW);
 #endif //BACKGROUND_GC
     }
 #endif // FEATURE_REDHAWK
index 31f3d1d..c391ef8 100644 (file)
@@ -207,6 +207,12 @@ ALWAYS_INLINE void GCToEEInterface::EnableFinalization(bool foundFinalizers)
     g_theGCToCLR->EnableFinalization(foundFinalizers);
 }
 
+ALWAYS_INLINE void GCToEEInterface::HandleFatalError(unsigned int exitCode)
+{
+    assert(g_theGCToCLR != nullptr);
+    g_theGCToCLR->HandleFatalError(exitCode);
+}
+
 #undef ALWAYS_INLINE
 
 #endif // __GCTOENV_EE_STANDALONE_INL__
index 7c0eea2..da74665 100644 (file)
@@ -133,6 +133,10 @@ public:
     // be finalized.
     virtual
     void EnableFinalization(bool foundFinalizers) = 0;
+
+    // Signals to the EE that the GC encountered a fatal error and can't recover.
+    virtual
+    void HandleFatalError(unsigned int exitCode) = 0;
 };
 
 #endif // _GCINTERFACE_EE_H_
index 8403bba..b339fcc 100644 (file)
@@ -265,6 +265,11 @@ void GCToEEInterface::EnableFinalization(bool foundFinalizers)
     // TODO: Implement for finalization
 }
 
+void GCToEEInterface::HandleFatalError(unsigned int exitCode)
+{
+    abort();
+}
+
 bool IsGCSpecialThread()
 {
     // TODO: Implement for background GC
index 380c31a..bf2ce2c 100644 (file)
@@ -1340,3 +1340,7 @@ void GCToEEInterface::EnableFinalization(bool foundFinalizers)
     }
 }
 
+void GCToEEInterface::HandleFatalError(unsigned int exitCode)
+{
+    EEPOLICY_HANDLE_FATAL_ERROR(exitCode);
+}
index a7ab0b5..e3ced6c 100644 (file)
@@ -44,6 +44,7 @@ public:
     void StompWriteBarrier(WriteBarrierParameters* args);
 
     void EnableFinalization(bool foundFinalizers);
+    void HandleFatalError(unsigned int exitCode);
 };
 
 #endif // FEATURE_STANDALONE_GC