https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14940
--- Comment #49 from Martin Richter <xricht17 at stud dot fit.vutbr.cz> --- (In reply to Martin Richter from comment #47) My apologies, that patch is incorrect - `VirtualAlloc` still uses `pch_VA_max_size` instead of `size`. Some discussion about this bug and the reasoning behind the patch can be found here: https://sourceforge.net/p/mingw-w64/bugs/382/ Now the correct patch: diff --git a/gcc/config/i386/host-mingw32.c b/gcc/config/i386/host-mingw32.c index aa17378..631d9c4 100644 --- a/gcc/config/i386/host-mingw32.c +++ b/gcc/config/i386/host-mingw32.c @@ -42,9 +42,6 @@ static size_t mingw32_gt_pch_alloc_granularity (void); static inline void w32_error(const char*, const char*, int, const char*); -/* FIXME: Is this big enough? */ -static const size_t pch_VA_max_size = 128 * 1024 * 1024; - /* Granularity for reserving address space. */ static size_t va_granularity = 0x10000; @@ -86,9 +83,6 @@ static void * mingw32_gt_pch_get_address (size_t size, int) { void* res; - size = (size + va_granularity - 1) & ~(va_granularity - 1); - if (size > pch_VA_max_size) - return NULL; /* FIXME: We let system determine base by setting first arg to NULL. Allocating at top of available address space avoids unnecessary @@ -98,7 +92,7 @@ mingw32_gt_pch_get_address (size_t size, int) If we allocate at bottom we need to reserve the address as early as possible and at the same point in each invocation. */ - res = VirtualAlloc (NULL, pch_VA_max_size, + res = VirtualAlloc (NULL, size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_NOACCESS); if (!res) @@ -148,7 +142,7 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd, /* Offset must be also be a multiple of allocation granularity for this to work. We can't change the offset. */ - if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size) + if ((offset & (va_granularity - 1)) != 0) return -1;