In intGCShadow() first reserve memory before committing. VirtualCommit does not accep...
authorRahul Kumar <rahku@microsoft.com>
Sat, 13 Aug 2016 00:29:02 +0000 (17:29 -0700)
committerRahul Kumar <rahku@microsoft.com>
Sat, 13 Aug 2016 00:29:02 +0000 (17:29 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/13d46168b98198cbc1fe4e54b6a54e5f03ee35b7

src/coreclr/src/gc/gc.cpp

index 3300421..08ae56f 100644 (file)
@@ -36705,12 +36705,8 @@ void initGCShadow()
     if (len > (size_t)(g_GCShadowEnd - g_GCShadow)) 
     {
         deleteGCShadow();
-        g_GCShadowEnd = g_GCShadow = (uint8_t*) GCToOSInterface::VirtualCommit(0, len);
-        if (g_GCShadow)
-        {
-            g_GCShadowEnd += len;
-        }
-        else
+        g_GCShadowEnd = g_GCShadow = (uint8_t *)GCToOSInterface::VirtualReserve(0, len, 0,VirtualReserveFlags::None);
+        if(!GCToOSInterface::VirtualCommit(g_GCShadow, len))
         {
             _ASSERTE(!"Not enough memory to run HeapVerify level 2");
             // If after the assert we decide to allow the program to continue 
@@ -36719,7 +36715,9 @@ void initGCShadow()
             // ensure calls to updateGCShadow() checkGCWriteBarrier() don't AV
             return;
         }
-        }
+        
+        g_GCShadowEnd += len;
+    }
 
     // save the value of g_lowest_address at this time.  If this value changes before
     // the next call to checkGCWriteBarrier() it means we extended the heap (with a