[commit: ghc] ghc-8.6: rts/M32Alloc: Abort if m32 linker mmap fails (c8b24dc)

git at git.haskell.org git at git.haskell.org
Thu Nov 22 21:54:56 UTC 2018


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

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/c8b24dce7bba394ca60c8eba04c5bed7a7e9534e/ghc

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

commit c8b24dce7bba394ca60c8eba04c5bed7a7e9534e
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Nov 10 15:35:37 2018 -0500

    rts/M32Alloc: Abort if m32 linker mmap fails
    
    Previously we should just blinding dereference a NULL pointer.
    
    (cherry picked from commit 86f6890e3689f2f75ecca8172eda0338fe3e9769)


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

c8b24dce7bba394ca60c8eba04c5bed7a7e9534e
 rts/linker/M32Alloc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rts/linker/M32Alloc.c b/rts/linker/M32Alloc.c
index 6a2996d..52b182e 100644
--- a/rts/linker/M32Alloc.c
+++ b/rts/linker/M32Alloc.c
@@ -158,6 +158,9 @@ m32_allocator_init(void)
    // fragment the memory.
    size_t pgsz = getPageSize();
    char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0);
+   if (bigchunk == NULL)
+       barf("m32_allocator_init: Failed to map");
+
    int i;
    for (i=0; i<M32_MAX_PAGES; i++) {
       alloc.pages[i].base_addr = bigchunk + i*pgsz;



More information about the ghc-commits mailing list