summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-24 14:40:33 (GMT)
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-01 07:29:23 (GMT)
commit58ed6c4a0999c0025b1b024bc26171fa6d6773b3 (patch)
tree5c9737af1c239b4b5e0b7e03114fba514fddae16
parent913287a0fa5370a2488ce560f2dfba61db51055d (diff)
downloadghc-58ed6c4a0999c0025b1b024bc26171fa6d6773b3.zip
ghc-58ed6c4a0999c0025b1b024bc26171fa6d6773b3.tar.gz
ghc-58ed6c4a0999c0025b1b024bc26171fa6d6773b3.tar.bz2
rts/M32Alloc: Don't attempt to unmap non-existent pages
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 6f61a5c..1a19df8 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);