From: Ivan Maidanski Date: Thu, 20 Dec 2018 23:33:49 +0000 (+0300) Subject: Abort with appropriate message if executable pages cannot be allocated X-Git-Tag: v8.0.2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3d845314f9a4678798beeb62fc9ce629e4addee;p=gc Abort with appropriate message if executable pages cannot be allocated This may happen e.g. if PaX MPROTECT feature is enabled. * os_dep.c [!OS2 && !PCR && !AMIGA && !USE_WINALLOC && !MACOS && !DOS4GW && !NONSTOP && !SN_TARGET_PSP2 && !RTEMS && !__CC_ARM && MMAP_SUPPORTED] (GC_unix_mmap_get_mem): Treat result==MAP_FAILED as unlikely; if the first mmap call returns MAP_FAILED then ABORT with the appropriate message if GC_pages_executable (and errno is EACCES). --- diff --git a/os_dep.c b/os_dep.c index 9de7378c..2f16481e 100644 --- a/os_dep.c +++ b/os_dep.c @@ -2184,7 +2184,11 @@ void GC_register_data_segments(void) GC_MMAP_FLAGS | OPT_MAP_ANON, zero_fd, 0/* offset */); # undef IGNORE_PAGES_EXECUTABLE - if (result == MAP_FAILED) return(0); + if (EXPECT(MAP_FAILED == result, FALSE)) { + if (HEAP_START == last_addr && GC_pages_executable && EACCES == errno) + ABORT("Cannot allocate executable pages"); + return NULL; + } last_addr = (ptr_t)(((word)result + bytes + GC_page_size - 1) & ~(GC_page_size - 1)); # if !defined(LINUX)