@@ -16566,6 +16566,7 @@ DebuggerHeap::DebuggerHeap()
16566
16566
#ifdef USE_INTEROPSAFE_HEAP
16567
16567
m_hHeap = NULL;
16568
16568
#endif
16569
+ m_fExecutable = FALSE;
16569
16570
}
16570
16571
16571
16572
@@ -16615,6 +16616,7 @@ HRESULT DebuggerHeap::Init(BOOL fExecutable)
16615
16616
16616
16617
// Have knob catch if we don't want to lazy init the debugger.
16617
16618
_ASSERTE(!g_DbgShouldntUseDebugger);
16619
+ m_fExecutable = fExecutable;
16618
16620
16619
16621
#ifdef USE_INTEROPSAFE_HEAP
16620
16622
// If already inited, then we're done.
@@ -16742,14 +16744,17 @@ void *DebuggerHeap::Alloc(DWORD size)
16742
16744
#endif
16743
16745
16744
16746
#ifdef FEATURE_PAL
16745
- // We don't have executable heap in PAL, but we still need to allocate
16746
- // executable memory, that's why have change protection level for
16747
- // each allocation.
16748
- // UNIXTODO: We need to look how JIT solves this problem.
16749
- DWORD unusedFlags;
16750
- if (!VirtualProtect(ret, size, PAGE_EXECUTE_READWRITE, &unusedFlags))
16751
- {
16752
- _ASSERTE(!"VirtualProtect failed to make this memory executable");
16747
+ if (m_fExecutable)
16748
+ {
16749
+ // We don't have executable heap in PAL, but we still need to allocate
16750
+ // executable memory, that's why have change protection level for
16751
+ // each allocation.
16752
+ // UNIXTODO: We need to look how JIT solves this problem.
16753
+ DWORD unusedFlags;
16754
+ if (!VirtualProtect(ret, size, PAGE_EXECUTE_READWRITE, &unusedFlags))
16755
+ {
16756
+ _ASSERTE(!"VirtualProtect failed to make this memory executable");
16757
+ }
16753
16758
}
16754
16759
#endif // FEATURE_PAL
16755
16760
@@ -16797,14 +16802,17 @@ void *DebuggerHeap::Realloc(void *pMem, DWORD newSize, DWORD oldSize)
16797
16802
16798
16803
16799
16804
#ifdef FEATURE_PAL
16800
- // We don't have executable heap in PAL, but we still need to allocate
16801
- // executable memory, that's why have change protection level for
16802
- // each allocation.
16803
- // UNIXTODO: We need to look how JIT solves this problem.
16804
- DWORD unusedFlags;
16805
- if (!VirtualProtect(ret, newSize, PAGE_EXECUTE_READWRITE, &unusedFlags))
16806
- {
16807
- _ASSERTE(!"VirtualProtect failed to make this memory executable");
16805
+ if (m_fExecutable)
16806
+ {
16807
+ // We don't have executable heap in PAL, but we still need to allocate
16808
+ // executable memory, that's why have change protection level for
16809
+ // each allocation.
16810
+ // UNIXTODO: We need to look how JIT solves this problem.
16811
+ DWORD unusedFlags;
16812
+ if (!VirtualProtect(ret, newSize, PAGE_EXECUTE_READWRITE, &unusedFlags))
16813
+ {
16814
+ _ASSERTE(!"VirtualProtect failed to make this memory executable");
16815
+ }
16808
16816
}
16809
16817
#endif // FEATURE_PAL
16810
16818
0 commit comments