summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-25 10:54:31 -0500
committerBen Gamari <ben@smart-cactus.org>2020-11-25 11:25:13 -0500
commit839255bc7ce4f5472144185766ad206350c14c3d (patch)
tree6da326c0cab8b093cb79abc874cd13a4dfc77b08
parent2ed3e6c0f179c06828712832d1176519cdfa82a6 (diff)
downloadhaskell-wip/win32-high-heap.tar.gz
rts: Allocate MBlocks with MAP_TOP_DOWN on Windowswip/win32-high-heap
As noted in #18991, we would previously allocate heap in low memory. Due to this the linker, which typically *needs* low memory, would end up competing with the heap. In longer builds we end up running out of low memory entirely, leading to linking failures.
-rw-r--r--rts/win32/OSMem.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c
index dd53f4d589..138660a879 100644
--- a/rts/win32/OSMem.c
+++ b/rts/win32/OSMem.c
@@ -50,8 +50,11 @@ allocNew(uint32_t n) {
alloc_rec* rec;
rec = (alloc_rec*)stgMallocBytes(sizeof(alloc_rec),"getMBlocks: allocNew");
rec->size = ((W_)n+1)*MBLOCK_SIZE;
+ // N.B. We use MEM_TOP_DOWN here to ensure that we leave the bottom of the
+ // address space available for the linker and libraries, which in general
+ // want to live in low memory. See #18991.
rec->base =
- VirtualAlloc(NULL, rec->size, MEM_RESERVE, PAGE_READWRITE);
+ VirtualAlloc(NULL, rec->size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE);
if(rec->base==0) {
stgFree((void*)rec);
rec=0;