Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/platform-macos.cc

Issue 7352007: Add guard pages in front of platform allocations (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform-macos.cc
===================================================================
--- src/platform-macos.cc (revision 8619)
+++ src/platform-macos.cc (working copy)
@@ -148,7 +148,7 @@
bool is_executable) {
const size_t msize = RoundUp(requested, getpagesize());
int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
- void* mbase = mmap(NULL, msize, prot,
+ void* mbase = mmap(NULL, msize + Page::kPageSize, prot,
MAP_PRIVATE | MAP_ANON,
kMmapFd, kMmapFdOffset);
if (mbase == MAP_FAILED) {
@@ -156,6 +156,8 @@
return NULL;
}
*allocated = msize;
+ mprotect(mbase, Page::kPageSize, PROT_NONE);
+ mbase += Page::kPageSize;
UpdateAllocatedSpaceLimits(mbase, msize);
return mbase;
}
@@ -163,7 +165,7 @@
void OS::Free(void* address, const size_t size) {
// TODO(1240712): munmap has a return value which is ignored here.
- int result = munmap(address, size);
+ int result = munmap(address - Page::kPageSize, size + Page::kPageSize);
USE(result);
ASSERT(result == 0);
}

Powered by Google App Engine
This is Rietveld 408576698