Bug 1321286 - Disable protection on Beta and Release builds. r=jandem
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Wed, 30 Nov 2016 06:04:00 +0100
changeset 325377 e333afeac179b7919eef15620782e5ee0bda35f3
parent 325376 1e325da15c787fffcddeeba92ea24b99e0d8d097
child 325378 d7a7e352abec80fbe76fb1f9bf235e2272c1e917
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjandem
bugs1321286
milestone53.0a1
Bug 1321286 - Disable protection on Beta and Release builds. r=jandem
js/src/ds/MemoryProtectionExceptionHandler.cpp
js/src/ds/PageProtectingVector.h
--- a/js/src/ds/MemoryProtectionExceptionHandler.cpp
+++ b/js/src/ds/MemoryProtectionExceptionHandler.cpp
@@ -98,16 +98,19 @@ MemoryProtectionExceptionHandler::isDisa
 #if defined(XP_WIN) && defined(MOZ_ASAN)
     // Under Windows ASan, WasmFaultHandler registers itself at 'last' priority
     // in order to let ASan's ShadowExceptionHandler stay at 'first' priority.
     // Unfortunately that results in spurious wasm faults passing through the
     // MemoryProtectionExceptionHandler, which breaks its assumption that any
     // faults it sees are fatal. Just disable this handler in that case, as the
     // crash annotations provided here are not critical for ASan builds.
     return true;
+#elif defined(RELEASE_OR_BETA)
+    // Disable the exception handler for Beta and Release builds.
+    return true;
 #else
     return false;
 #endif
 }
 
 void
 MemoryProtectionExceptionHandler::addRegion(void* addr, size_t size)
 {
--- a/js/src/ds/PageProtectingVector.h
+++ b/js/src/ds/PageProtectingVector.h
@@ -68,18 +68,20 @@ class PageProtectingVector final
 
     bool protectionEnabled;
     bool regionUnprotected;
 
     void updateOffsetToPage() {
         unprotectedBytes += offsetToPage;
         offsetToPage = (pageSize - (uintptr_t(vector.begin()) & pageMask)) & pageMask;
         unprotectedBytes -= offsetToPage;
+#ifndef RELEASE_OR_BETA
         protectionEnabled = vector.capacity() >= protectionLowerBound &&
                             vector.capacity() >= pageSize + offsetToPage;
+#endif
     }
 
     void protect() {
         if (!regionUnprotected && protectionEnabled && unprotectedBytes >= intptr_t(pageSize)) {
             size_t toProtect = size_t(unprotectedBytes) & ~pageMask;
             uintptr_t addr = uintptr_t(vector.begin()) + offsetToPage + protectedBytes;
             gc::MakePagesReadOnly(reinterpret_cast<void*>(addr), toProtect);
             unprotectedBytes -= toProtect;