Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit de69718

Browse files
authored
Partial revert "Fix problem with virtual memory commit in OOM scenario on Linux (#5609)" (#5744)
#5609 is suspect to cause intermittent crashes on OS X. Keep the fix for Linux, but revert to using the original code on OS X.
1 parent 63d9a2e commit de69718

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/pal/src/map/virtual.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,17 @@ static LPVOID VIRTUALCommitMemory(
11141114
if (allocationType != MEM_COMMIT)
11151115
{
11161116
// Commit the pages
1117+
void * pRet = MAP_FAILED;
1118+
#ifndef __APPLE__
11171119
if (mprotect((void *) StartBoundary, MemSize, PROT_WRITE | PROT_READ) == 0)
1120+
pRet = (void *)StartBoundary;
1121+
#else // __APPLE__
1122+
// Using mprotect above on MacOS is suspect to cause intermittent crashes
1123+
// https://github.com/dotnet/coreclr/issues/5672
1124+
pRet = mmap((void *) StartBoundary, MemSize, PROT_WRITE | PROT_READ,
1125+
MAP_ANON | MAP_FIXED | MAP_PRIVATE, -1, 0);
1126+
#endif // __APPLE__
1127+
if (pRet != MAP_FAILED)
11181128
{
11191129
#if MMAP_DOESNOT_ALLOW_REMAP
11201130
SIZE_T i;

0 commit comments

Comments
 (0)