From 2ff908525e42580e410d9d0f7831c20645006b56 Mon Sep 17 00:00:00 2001 From: Christian Holler Date: Mon, 29 Jul 2013 02:44:00 +0200 Subject: [PATCH] Bug 898230 - Disable alloc-dealloc checking under AddressSanitizer. r=glandium --- js/src/ion/AsmJSSignalHandlers.cpp | 11 ----------- mozglue/build/AsanOptions.cpp | 24 ++++++++++++++++++++++++ mozglue/build/moz.build | 4 ++++ 3 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 mozglue/build/AsanOptions.cpp diff --git a/js/src/ion/AsmJSSignalHandlers.cpp b/js/src/ion/AsmJSSignalHandlers.cpp index c32a952241a..c6105b6372e 100644 --- a/js/src/ion/AsmJSSignalHandlers.cpp +++ b/js/src/ion/AsmJSSignalHandlers.cpp @@ -996,14 +996,3 @@ js::TriggerOperationCallbackForAsmJSCode(JSRuntime *rt) 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 diff --git a/mozglue/build/AsanOptions.cpp b/mozglue/build/AsanOptions.cpp new file mode 100644 index 00000000000..0b516e0c68f --- /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"; +} diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index f2b3f2d54bd..99b88f85f6f 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -45,6 +45,10 @@ if CONFIG['CPU_ARCH'] == 'arm': 'arm.cpp', ] +if CONFIG['MOZ_ASAN']: + CPP_SOURCES += [ + 'AsanOptions.cpp', + ] LIBRARY_NAME = 'mozglue'