From 40b0aa5b3ec4eaef4e1479866cf4868f4a9a0ba0 Mon Sep 17 00:00:00 2001 From: Seth Jackson Date: Tue, 21 Apr 2026 03:41:53 -0400 Subject: [PATCH 1/2] Fix map/virtual.cpp on OpenBSD --- src/coreclr/pal/src/map/virtual.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index ea7e7e52c96877..7695c00f17f223 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -716,7 +716,7 @@ VIRTUALCommitMemory( nProtect = W32toUnixAccessControl(flProtect); pRetVal = (void *) StartBoundary; - + #ifndef TARGET_WASM // Commit the pages if (mprotect((void *) StartBoundary, MemSize, nProtect) != 0) @@ -1581,8 +1581,13 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory() int32_t sizeOfAllocation = MaxExecutableMemorySizeNearCoreClr; int32_t initialReserveLimit = -1; + #if !defined(TARGET_OPENBSD) + int addressSpace = RLIMIT_AS; + #else + int addressSpace = RLIMIT_DATA; + #endif rlimit addressSpaceLimit; - if ((getrlimit(RLIMIT_AS, &addressSpaceLimit) == 0) && (addressSpaceLimit.rlim_cur != RLIM_INFINITY)) + if ((getrlimit(addressSpace, &addressSpaceLimit) == 0) && (addressSpaceLimit.rlim_cur != RLIM_INFINITY)) { // By default reserve max 20% of the available virtual address space rlim_t initialExecMemoryPerc = 20; From 33a2952e60e9ae084c426445a0e36143fe51c7c7 Mon Sep 17 00:00:00 2001 From: Seth Jackson Date: Tue, 21 Apr 2026 09:20:13 -0400 Subject: [PATCH 2/2] Update src/coreclr/pal/src/map/virtual.cpp Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- src/coreclr/pal/src/map/virtual.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 7695c00f17f223..043502e916acd1 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -1581,11 +1581,11 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory() int32_t sizeOfAllocation = MaxExecutableMemorySizeNearCoreClr; int32_t initialReserveLimit = -1; - #if !defined(TARGET_OPENBSD) +#ifdef RLIMIT_AS int addressSpace = RLIMIT_AS; - #else +#else int addressSpace = RLIMIT_DATA; - #endif +#endif rlimit addressSpaceLimit; if ((getrlimit(addressSpace, &addressSpaceLimit) == 0) && (addressSpaceLimit.rlim_cur != RLIM_INFINITY)) {