diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-11-11 00:06:54 +0300 |
---|---|---|
committer | Sergiy Kuryata <sergeyk@microsoft.com> | 2017-11-11 00:06:54 +0300 |
commit | f9bf1fc506347c30357a0d708bf69459f142eee4 (patch) | |
tree | eedbfb55667393003644652d48372827b7fc8f24 /src/Native/Runtime/unix | |
parent | c22aab437100a45a6e721a8e773dc43a6a5b789e (diff) |
Fix implementation of GCToOSInterface::VirtualCommit to ditch the pages (#4907)
The GC depends on the pages to be zeroed out when they are mapped in again
Diffstat (limited to 'src/Native/Runtime/unix')
-rw-r--r-- | src/Native/Runtime/unix/PalRedhawkUnix.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Native/Runtime/unix/PalRedhawkUnix.cpp b/src/Native/Runtime/unix/PalRedhawkUnix.cpp index 0357d6058..0c0c035e1 100644 --- a/src/Native/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/Native/Runtime/unix/PalRedhawkUnix.cpp @@ -1537,7 +1537,12 @@ bool GCToOSInterface::VirtualCommit(void* address, size_t size) // true if it has succeeded, false if it has failed bool GCToOSInterface::VirtualDecommit(void* address, size_t size) { - return mprotect(address, size, PROT_NONE) == 0; + // TODO: This can fail, however the GC does not handle the failure gracefully + // Explicitly calling mmap instead of mprotect here makes it + // that much more clear to the operating system that we no + // longer need these pages. Also, GC depends on re-commited pages to + // be zeroed-out. + return mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != NULL; } // Reset virtual memory range. Indicates that data in the memory range specified by address and size is no |