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

Unified Diff: third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp

Issue 1903763002: Avoid PageAllocator::s_allocPageErrorCode races. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp
diff --git a/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp b/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp
index 854638758bd5366ce86515be419c95b48d4226e9..12c9a7b3b0e76f13dea6dc1c13738ca26a0eb3f9 100644
--- a/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp
+++ b/third_party/WebKit/Source/wtf/allocator/PageAllocator.cpp
@@ -31,6 +31,7 @@
#include "wtf/allocator/PageAllocator.h"
#include "wtf/Assertions.h"
+#include "wtf/Atomics.h"
#include "wtf/allocator/AddressSpaceRandomization.h"
#include <limits.h>
@@ -50,7 +51,7 @@
// On POSIX memmap uses a nearby address if the hint address is blocked.
static const bool kHintIsAdvisory = true;
-static uint32_t allocPageErrorCode = 0;
+static uint32_t s_allocPageErrorCode = 0;
#elif OS(WIN)
@@ -58,7 +59,7 @@ static uint32_t allocPageErrorCode = 0;
// VirtualAlloc will fail if allocation at the hint address is blocked.
static const bool kHintIsAdvisory = false;
-static uint32_t allocPageErrorCode = ERROR_SUCCESS;
+static uint32_t s_allocPageErrorCode = ERROR_SUCCESS;
#else
#error Unknown OS
@@ -80,12 +81,12 @@ static void* systemAllocPages(void* hint, size_t len, PageAccessibilityConfigura
DWORD accessFlag = pageAccessibility == PageAccessible ? PAGE_READWRITE : PAGE_NOACCESS;
ret = VirtualAlloc(hint, len, MEM_RESERVE | MEM_COMMIT, accessFlag);
if (!ret)
- allocPageErrorCode = GetLastError();
+ releaseStore(&s_allocPageErrorCode, GetLastError());
#else
int accessFlag = pageAccessibility == PageAccessible ? (PROT_READ | PROT_WRITE) : PROT_NONE;
ret = mmap(hint, len, accessFlag, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (ret == MAP_FAILED) {
- allocPageErrorCode = errno;
+ releaseStore(&s_allocPageErrorCode, errno);
ret = 0;
}
#endif
@@ -270,7 +271,7 @@ void discardSystemPages(void* addr, size_t len)
uint32_t getAllocPageErrorCode()
{
- return allocPageErrorCode;
+ return acquireLoad(&s_allocPageErrorCode);
}
} // namespace WTF
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698