summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-24 09:40:33 -0500
committerGabor Greif <ggreif@gmail.com>2020-01-25 19:35:24 -0500
commit9f731e013d7c91a34cbb276b21fec45f34b8d5dd (patch)
tree3b66c83225e6d059f285b8bdfe72f16cdecefdd4
parentb3e5c678851ed73897b0eb337e656ff377d242c9 (diff)
downloadhaskell-wip/fix-m32-unmap.tar.gz
rts/M32Alloc: Don't attempt to unmap non-existent pageswip/fix-m32-unmap
The m32 allocator's `pages` list may contain NULLs in the case that the page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't like it if we pass them NULL. Don't do that.
-rw-r--r--rts/linker/M32Alloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/rts/linker/M32Alloc.c b/rts/linker/M32Alloc.c
index 6f61a5c447..1a19df8471 100644
--- a/rts/linker/M32Alloc.c
+++ b/rts/linker/M32Alloc.c
@@ -317,7 +317,9 @@ void m32_allocator_free(m32_allocator *alloc)
/* free partially-filled pages */
const size_t pgsz = getPageSize();
for (int i=0; i < M32_MAX_PAGES; i++) {
- munmapForLinker(alloc->pages[i], pgsz);
+ if (alloc->pages[i]) {
+ munmapForLinker(alloc->pages[i], pgsz);
+ }
}
stgFree(alloc);