mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
deps: backport 3a9bfec from v8 upstream
Some of the logic from `zone.cc` is found in `zone-inl.h` in this release stream. Original commit message: Fix overflow issue in Zone::New When requesting a large allocation near the end of the address space, the computation could overflow and erroneously *not* grow the Zone as required. BUG=chromium:606115 LOG=y Review-Url: https://codereview.chromium.org/1930873002 Cr-Commit-Position: refs/heads/master@{#35903} PR-URL: https://github.com/nodejs/node-private/pull/43 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
1 parent
ffc55f7eac
commit
fcb9145e29
2 files changed
+8
-2
No files matched your search
Vendored
+4
-1
@@ -55,7 +55,10 @@ inline void* Zone::New(int size) {
|
|||||||
// Check if the requested size is available without expanding.
|
// Check if the requested size is available without expanding.
|
||||||
Address result = position_;
|
Address result = position_;
|
||||||
|
|
||||||
if (size > limit_ - position_) {
|
const uintptr_t limit = reinterpret_cast<uintptr_t>(limit_);
|
||||||
|
const uintptr_t position = reinterpret_cast<uintptr_t>(position_);
|
||||||
|
// position_ > limit_ can be true after the alignment correction above.
|
||||||
|
if (limit < position || size > limit - position) {
|
||||||
result = NewExpand(size);
|
result = NewExpand(size);
|
||||||
} else {
|
} else {
|
||||||
position_ += size;
|
position_ += size;
|
||||||
|
|||||||
Vendored
+4
-1
@@ -168,7 +168,10 @@ Address Zone::NewExpand(int size) {
|
|||||||
// Make sure the requested size is already properly aligned and that
|
// Make sure the requested size is already properly aligned and that
|
||||||
// there isn't enough room in the Zone to satisfy the request.
|
// there isn't enough room in the Zone to satisfy the request.
|
||||||
ASSERT(size == RoundDown(size, kAlignment));
|
ASSERT(size == RoundDown(size, kAlignment));
|
||||||
ASSERT(size > limit_ - position_);
|
ASSERT(limit_ < position_ ||
|
||||||
|
reinterpret_cast<uintptr_t>(limit_) -
|
||||||
|
reinterpret_cast<uintptr_t>(position_) <
|
||||||
|
size);
|
||||||
|
|
||||||
// Compute the new segment size. We use a 'high water mark'
|
// Compute the new segment size. We use a 'high water mark'
|
||||||
// strategy, where we increase the segment size every time we expand
|
// strategy, where we increase the segment size every time we expand
|
||||||
|
|||||||
Reference in new issue
Block a user