[commit: ghc] ghc-8.2: fix a memory leak in osNumaMask (2a5f7b3)

git at git.haskell.org git at git.haskell.org
Mon May 22 19:21:30 UTC 2017


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

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

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

commit 2a5f7b3c1e1e75aedac76f7de40d2b6410928356
Author: Kubo Kovac <kuko at fb.com>
Date:   Mon May 22 11:51:55 2017 -0400

    fix a memory leak in osNumaMask
    
    got an error when using asan:
    ```
    ==1866689==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 16 byte(s) in 1 object(s) allocated from:
        #0 0x10640568 in malloc ??:?
        #1 0x154d867e in numa_bitmask_alloc .../numactl-2.0.8/libnuma_nosymve r.c:204
        #2 0x154d867e in numa_allocate_nodemask .../numactl-2.0.8/libnuma_nosymve r.c:724
        #3 0x154d867e in numa_get_mems_allowed .../numactl-2.0.8/libnuma_nosymve r.c:1141
        #4 0x10b54a45 in osNumaMask ...ghc-8.0.2/rts/posix/OSMem.c:59 8
    ```
    
    Test Plan: compile, validate
    
    Reviewers: simonmar, niteria, austin, bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3537
    
    (cherry picked from commit 83ee930fdd125d74939307ed3fa1bf6a2ba7fb36)


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

2a5f7b3c1e1e75aedac76f7de40d2b6410928356
 rts/posix/OSMem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index dcf734f..e2aa288 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -601,7 +601,9 @@ uint64_t osNumaMask(void)
     if (osNumaNodes() > sizeof(StgWord)*8) {
         barf("osNumaMask: too many NUMA nodes (%d)", osNumaNodes());
     }
-    return mask->maskp[0];
+    uint64_t r = mask->maskp[0];
+    numa_bitmask_free(mask);
+    return r;
 #else
     return 1;
 #endif



More information about the ghc-commits mailing list