Selective VirtualProtect in debugger heap for Realloc
authorEugene <Eugene.Zemtsov@microsoft.com>
Thu, 5 Nov 2015 22:42:54 +0000 (14:42 -0800)
committerEugene <Eugene.Zemtsov@microsoft.com>
Thu, 5 Nov 2015 22:59:28 +0000 (14:59 -0800)
src/debug/ee/debugger.cpp

index 2662118..613a64e 100644 (file)
@@ -16802,14 +16802,17 @@ void *DebuggerHeap::Realloc(void *pMem, DWORD newSize, DWORD oldSize)
 
 
 #ifdef FEATURE_PAL
-    // We don't have executable heap in PAL, but we still need to allocate 
-    // executable memory, that's why have change protection level for 
-    // each allocation. 
-    // UNIXTODO: We need to look how JIT solves this problem.
-    DWORD unusedFlags;
-    if (!VirtualProtect(ret, newSize, PAGE_EXECUTE_READWRITE, &unusedFlags))
-    {
-        _ASSERTE(!"VirtualProtect failed to make this memory executable");
+    if (m_fExecutable)
+    {    
+        // We don't have executable heap in PAL, but we still need to allocate 
+        // executable memory, that's why have change protection level for 
+        // each allocation. 
+        // UNIXTODO: We need to look how JIT solves this problem.
+        DWORD unusedFlags;
+        if (!VirtualProtect(ret, newSize, PAGE_EXECUTE_READWRITE, &unusedFlags))
+        {
+            _ASSERTE(!"VirtualProtect failed to make this memory executable");
+        }
     }
 #endif // FEATURE_PAL