Commit 7e012aea authored by Mark Williams's avatar Mark Williams Committed by Facebook Github Bot

Fix a GuardPageAllocator range check

Summary:
The range check to identify its "own" memory could inadvertently pick
up an allocation from outside the range, resulting in an alignment
assertion later on, and causing us to permanently leak the memory
(when assertions are disabled).

Reviewed By: alikhtarov, andriigrynenko

Differential Revision: D7146394

fbshipit-source-id: d9d8b63eea1ffa045e1bd07c0258d1f2b089e9bf
parent 5b1c46fb
......@@ -116,12 +116,13 @@ class StackCache {
assert(storage_);
auto as = allocSize(size);
auto p = limit + size - as;
if (p < storage_ || p >= storage_ + allocSize_ * kNumGuarded) {
if (std::less_equal<void*>{}(limit, storage_) ||
std::less_equal<void*>{}(storage_ + allocSize_ * kNumGuarded, limit)) {
/* not mine */
return false;
}
auto p = limit + size - as;
assert(as == allocSize_);
assert((p - storage_) % allocSize_ == 0);
freeList_.emplace_back(p, /* protected= */ true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment