Permalink
Browse files

Common: fix MAP_32BIT after 9f24203

9f24203 added 0x20000000 as a default fallback address hint which
unconditionally disabled MAP_32BIT. FreeBSD cannot use the hints
because without adjusting RLIMIT_DATA lower addresses are reserved for
brk(2) style heap. So, don't try to use hints with MAP_32BIT.
  • Loading branch information...
jbeich committed Jul 21, 2017
1 parent f8213a9 commit e33acdc5e9226cb4825de8b9d858f65553a8ed93
Showing with 3 additions and 3 deletions.
  1. +3 −3 Common/MemoryUtil.cpp
View
@@ -157,7 +157,7 @@ void *AllocateExecutableMemory(size_t size) {
}
#else
static char *map_hint = 0;
#if defined(_M_X64)
#if defined(_M_X64) && !defined(MAP_32BIT)
// Try to request one that is close to our memory location if we're in high memory.
// We use a dummy global variable to give us a good location to start from.
if (!map_hint) {
@@ -179,7 +179,7 @@ void *AllocateExecutableMemory(size_t size) {
void* ptr = mmap(map_hint, size, prot,
MAP_ANON | MAP_PRIVATE
#if defined(_M_X64) && defined(MAP_32BIT)
| ((uintptr_t) map_hint == 0 ? MAP_32BIT : 0)
| MAP_32BIT
#endif
, -1, 0);
@@ -196,7 +196,7 @@ void *AllocateExecutableMemory(size_t size) {
ERROR_LOG(MEMMAP, "Failed to allocate executable memory (%d)", (int)size);
PanicAlert("Failed to allocate executable memory\n%s", GetLastErrorMsg());
}
#if defined(_M_X64) && !defined(_WIN32)
#if defined(_M_X64) && !defined(_WIN32) && !defined(MAP_32BIT)
else if ((uintptr_t)map_hint <= 0xFFFFFFFF) {
// Round up if we're below 32-bit mark, probably allocating sequentially.
map_hint += round_page(size);

0 comments on commit e33acdc

Please sign in to comment.