Skip to content

Commit

Permalink
[Fuchsia] Fix memory leak in gin::PageAllocator::ReleasePages()
Browse files Browse the repository at this point in the history
On all non-posix platforms ReleasePages() was calling
base::DecommitSystemPages() instead of freeing these pages. On Windows
that doesn't cause the leak because the pages will be freed later when
the whole region is released. That's not the case on other platforms,
particularly Fuchsia. As result ReleasePages() was essentially leaking
memory on Fuchsia.

Bug: 993541
Change-Id: I6d3c14184d553ea32ef28e64843e1f1915979ee6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752877
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686941}
  • Loading branch information
SergeyUlanov authored and Commit Bot committed Aug 14, 2019
1 parent a324768 commit 87233fb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gin/v8_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ class PageAllocator : public v8::PageAllocator {
DCHECK_LT(new_length, length);
uint8_t* release_base = reinterpret_cast<uint8_t*>(address) + new_length;
size_t release_size = length - new_length;
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
// On POSIX, we can unmap the trailing pages.
base::FreePages(release_base, release_size);
#else // defined(OS_WIN)
// On Windows, we can only de-commit the trailing pages.
#elif defined(OS_WIN)
// On Windows, we can only de-commit the trailing pages. FreePages() will
// still free all pages in the region including the released tail, so it's
// safe to just decommit the tail.
base::DecommitSystemPages(release_base, release_size);
#else
#error Unsupported platform
#endif
return true;
}
Expand Down

0 comments on commit 87233fb

Please sign in to comment.