Bug 898230 - Disable alloc-dealloc checking under AddressSanitizer. r=glandium
authorChristian Holler <choller@mozilla.com>
Mon, 29 Jul 2013 02:44:00 +0200
changeset 140286 4f899e59e268609ac31949372beeefcfd5fbbec6
parent 140285 d6fd6156acc3de1fb22f7b55fa3e5a51b3082b81
child 140287 91b749fdbf32b5350f04f0934e0fcc7d5ad16e1c
push id25023
push useremorley@mozilla.com
push dateMon, 29 Jul 2013 14:13:44 +0000
treeherdermozilla-central@8c89fe2a5c92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs898230
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898230 - Disable alloc-dealloc checking under AddressSanitizer. r=glandium
js/src/ion/AsmJSSignalHandlers.cpp
mozglue/build/AsanOptions.cpp
mozglue/build/moz.build
--- a/js/src/ion/AsmJSSignalHandlers.cpp
+++ b/js/src/ion/AsmJSSignalHandlers.cpp
@@ -991,19 +991,8 @@ js::TriggerOperationCallbackForAsmJSCode
     DWORD oldProtect;
     if (!VirtualProtect(module.functionCode(), module.functionBytes(), PAGE_NOACCESS, &oldProtect))
         MOZ_CRASH();
 #else  // assume Unix
     if (mprotect(module.functionCode(), module.functionBytes(), PROT_NONE))
         MOZ_CRASH();
 #endif
 }
-
-#ifdef MOZ_ASAN
-// When running with asm.js under AddressSanitizer, we need to explicitely
-// tell AddressSanitizer to allow custom signal handlers because it will 
-// otherwise trigger ASan's SIGSEGV handler for the internal SIGSEGVs that 
-// asm.js would otherwise handle.
-extern "C" MOZ_ASAN_BLACKLIST
-const char* __asan_default_options() {
-    return "allow_user_segv_handler=1";
-}
-#endif
new file mode 100644
--- /dev/null
+++ b/mozglue/build/AsanOptions.cpp
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Attributes.h"
+
+// When running with AddressSanitizer, we need to explicitely set some
+// options specific to our codebase to prevent errors during runtime.
+// 
+// Currently, these are:
+//
+//   allow_user_segv_handler=1 - Tell ASan to allow our code to use its
+//   own SIGSEGV handlers. This is required by ASM.js internally.
+//
+//   alloc_dealloc_mismatch=0 - Disable alloc-dealloc mismatch checking
+//   in ASan. This is required because we define our own new/delete
+//   operators that are backed by malloc/free. If one of them gets inlined
+//   while the other doesn't, ASan will report false positives.
+//
+extern "C" MOZ_ASAN_BLACKLIST
+const char* __asan_default_options() {
+    return "allow_user_segv_handler=1:alloc_dealloc_mismatch=0";
+}
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -40,12 +40,16 @@ if CONFIG['CPU_ARCH'].startswith('x86'):
         'SSE.cpp',
     ]
 
 if CONFIG['CPU_ARCH'] == 'arm':
     CPP_SOURCES += [
         'arm.cpp',
     ]
 
+if CONFIG['MOZ_ASAN']:
+    CPP_SOURCES += [
+        'AsanOptions.cpp',
+    ]
 
 
 LIBRARY_NAME = 'mozglue'