From efa5bdc6df45cea1543be95786fd554b60cf2a88 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Fri, 23 Jan 2026 11:45:00 +0100 Subject: [PATCH] Add better error message on VirtualAlloc failure on windows. --- src/utils/vmem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/vmem.c b/src/utils/vmem.c index eb109f76a..e3edda94b 100644 --- a/src/utils/vmem.c +++ b/src/utils/vmem.c @@ -65,7 +65,11 @@ static inline void* mmap_allocate(Vmem *vmem, size_t to_allocate) { size_t to_commit = blocks_to_allocate * COMMIT_PAGE_SIZE; void *res = VirtualAlloc(((char*)vmem->ptr) + vmem->committed, to_commit, MEM_COMMIT, PAGE_READWRITE); - if (!res) FATAL_ERROR("Failed to allocate more memory."); + if (!res) + { + error_exit("⚠️Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, " + "which was rejected. Perhaps you called some recursive macro?", (unsigned)(allocated_after / (1024 * 1024))); + } vmem->committed += to_commit; } #endif