rts/posix: Ensure that memory commit succeeds
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 16 Oct 2017 21:30:12 +0000 (17:30 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 16 Oct 2017 21:30:14 +0000 (17:30 -0400)
Previously we wouldn't check that mmap would succeed. I suspect this may
have been the cause of #14329.

Test Plan: Validate under low-memory condition

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14329

Differential Revision: https://phabricator.haskell.org/D4075

rts/posix/OSMem.c

index ee727a5..2f0bf3f 100644 (file)
@@ -534,7 +534,10 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
 
 void osCommitMemory(void *at, W_ size)
 {
-    my_mmap(at, size, MEM_COMMIT);
+    void *r = my_mmap(at, size, MEM_COMMIT);
+    if (r == NULL) {
+        barf("Unable to commit %d bytes of memory", size);
+    }
 }
 
 void osDecommitMemory(void *at, W_ size)