[commit: ghc] ghc-8.2: rts/posix: Ensure that memory commit succeeds (cb7f91d)

git at git.haskell.org git at git.haskell.org
Tue Oct 24 17:53:07 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/cb7f91db3e70cc36b2cc745e267adcb11c843f60/ghc

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

commit cb7f91db3e70cc36b2cc745e267adcb11c843f60
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
    
    (cherry picked from commit a69fa5441c944d7f74c76bdae9f3dd198007ee42)


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

cb7f91db3e70cc36b2cc745e267adcb11c843f60
 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 e2aa288..d25aaf8 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -521,7 +521,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