Rework the de-allocation guard on the munmap implementation
authorChristopher Dykes <cdykes@fb.com>
Tue, 6 Sep 2016 23:22:33 +0000 (16:22 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Tue, 6 Sep 2016 23:23:45 +0000 (16:23 -0700)
commit18914ab505d588f8c3dad9fd5b9133fe5495a870
tree0f8aeb2d616be630e6594467799dc2aa2e66c89e
parente64edf8025220bf74a2c38b8d38bd3a1d0a1e9eb
Rework the de-allocation guard on the munmap implementation

Summary:
The previous version assumed that `RegionSize` would always be the full size of the allocation done by `VirtualAlloc`. However, `RegionSize` actually only includes the following pages that have the same attributes, so, if you change the access permissions via `mprotect`, the `RegionSize` would exclude that region, which is not what was intended.
This instead stores the length and a dummy magic value after the end of the requested allocation.

Reviewed By: yfeldblum

Differential Revision: D3812949

fbshipit-source-id: 53bbbcc371accbed08adaffa82fc082ec44f316f
folly/portability/SysMman.cpp