From 0ab0232d2eadd68cf3973bc3f36ae5135d199a9a Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 27 Feb 2006 11:11:03 +0000 Subject: [PATCH] mmap() errors on Darwin: use errorBelch/exit instead of barf() The most likely cause is out-of-memory, not an RTS error. --- ghc/rts/MBlock.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ghc/rts/MBlock.c b/ghc/rts/MBlock.c index 331982d..8e07ee5 100644 --- a/ghc/rts/MBlock.c +++ b/ghc/rts/MBlock.c @@ -181,10 +181,14 @@ my_mmap (void *addr, lnat size) if(!addr || err) // try to allocate anywhere err = vm_allocate(mach_task_self(),(vm_address_t*) &ret, size, TRUE); - if(err) // don't know what the error codes mean exactly - barf("memory allocation failed (requested %lu bytes)", size); - else + if(err) { + // don't know what the error codes mean exactly, assume it's + // not our problem though. + errorBelch("memory allocation failed (requested %lu bytes)", size); + stg_exit(EXIT_FAILURE); + } else { vm_protect(mach_task_self(),ret,size,FALSE,VM_PROT_READ|VM_PROT_WRITE); + } #else ret = mmap(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); -- 1.7.10.4