Fix GCStress assertion
authorSteve MacLean <sdmaclea.qdt@qualcommdatacenter.com>
Tue, 29 May 2018 17:35:03 +0000 (13:35 -0400)
committerSteve MacLean <sdmaclea.qdt@qualcommdatacenter.com>
Tue, 29 May 2018 19:53:42 +0000 (15:53 -0400)
src/vm/gccover.cpp
src/vm/threads.h

index a604f85..ed7b037 100644 (file)
@@ -1728,7 +1728,12 @@ void DoGcStress (PCONTEXT regs, MethodDesc *pMD)
     // BUG(github #10318) - when not using allocation contexts, the alloc lock
     // must be acquired here. Until fixed, this assert prevents random heap corruption.
     assert(GCHeapUtilities::UseThreadAllocationContexts());
-    if (!GCHeapUtilities::GetGCHeap()->StressHeap(GetThread()->GetAllocContext()))
+    GCHeapUtilities::GetGCHeap()->StressHeap(GetThread()->GetAllocContext());
+
+    // StressHeap can exit early w/o forcing a SuspendEE to trigger the instruction update
+    // We can not rely on the return code to determine if the instruction update happened
+    // Use HasPendingGCStressInstructionUpdate() to be certain.
+    if(pThread->HasPendingGCStressInstructionUpdate())
         UpdateGCStressInstructionWithoutGC ();
 
     // Must flush instruction cache before returning as instruction has been modified.
index 70fcb52..16b0334 100644 (file)
@@ -4824,8 +4824,8 @@ public:
         LIMITED_METHOD_CONTRACT;
         PRECONDITION(!HasPendingGCStressInstructionUpdate());
 
-        m_pbDestCode = pbDestCode;
-        m_pbSrcCode = pbSrcCode;
+        VolatileStoreWithoutBarrier<BYTE*>(&m_pbSrcCode, pbSrcCode);
+        VolatileStore<BYTE*>(&m_pbDestCode, pbDestCode);
     }
     bool HasPendingGCStressInstructionUpdate()
     {
@@ -4838,8 +4838,8 @@ public:
         LIMITED_METHOD_CONTRACT;
         PRECONDITION(HasPendingGCStressInstructionUpdate());
 
-        m_pbDestCode = NULL;
-        m_pbSrcCode = NULL;
+        VolatileStoreWithoutBarrier<BYTE*>(&m_pbDestCode, NULL);
+        VolatileStore<BYTE*>(&m_pbSrcCode, NULL);
     }
 #if defined(GCCOVER_TOLERATE_SPURIOUS_AV)
     void SetLastAVAddress(LPVOID address)