diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-02-07 20:15:15 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-02-09 20:43:39 -0500 |
commit | 1db4f1fe7603c338ead0ac7e1ecfd0d8354d37bf (patch) | |
tree | b1cd23f936a7b149fa7c2f07485c9c29d4fe33be | |
parent | 4d3a306dce59649b303ac7aba56758aff3dee077 (diff) | |
download | haskell-1db4f1fe7603c338ead0ac7e1ecfd0d8354d37bf.tar.gz |
linker: Don't use MAP_FIXED
As noted in #21057, we really shouldn't be using MAP_FIXED. I would much
rather have the process crash with a "failed to map" error than randomly
overwrite existing mappings.
Closes #21057.
-rw-r--r-- | rts/linker/MMap.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/rts/linker/MMap.c b/rts/linker/MMap.c index 0fd12dcf5c..207e82ad2e 100644 --- a/rts/linker/MMap.c +++ b/rts/linker/MMap.c @@ -177,13 +177,10 @@ mmap_again: if ((W_)result > 0x80000000) { // oops, we were given memory over 2Gb munmap(result,size); -#if defined(freebsd_HOST_OS) || \ - defined(kfreebsdgnu_HOST_OS) || \ - defined(dragonfly_HOST_OS) - // Some platforms require MAP_FIXED. This is normally - // a bad idea, because MAP_FIXED will overwrite - // existing mappings. - fixed = MAP_FIXED; +#if defined(MAP_TRYFIXED) + // Some platforms require MAP_FIXED. We use MAP_TRYFIXED since + // MAP_FIXED will overwrite existing mappings. + fixed = MAP_TRYFIXED; goto mmap_again; #else reportMemoryMap(); |