[commit: ghc] master: rts/posix: Ensure that memory commit succeeds (a69fa54)

git at git.haskell.org git at git.haskell.org
Mon Oct 16 23:14:32 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a69fa5441c944d7f74c76bdae9f3dd198007ee42/ghc

>---------------------------------------------------------------

commit a69fa5441c944d7f74c76bdae9f3dd198007ee42
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Oct 16 17:30:12 2017 -0400

    rts/posix: Ensure that memory commit succeeds
    
    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


>---------------------------------------------------------------

a69fa5441c944d7f74c76bdae9f3dd198007ee42
 rts/posix/OSMem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index ee727a5..2f0bf3f 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -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)



More information about the ghc-commits mailing list