Enable AddressSanitizer by default in debug builds and tests.

Except when running BGMDriver because you have to change coreaudiod's
sandbox profile for that. And you have to disable SIP (rootless) to do
that.
This commit is contained in:
Kyle Neideck 2017-06-24 19:58:07 +10:00
parent 7f784b5d94
commit 9aec1aed34
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
6 changed files with 37 additions and 17 deletions

View file

@ -1060,6 +1060,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 1;
CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
@ -1103,7 +1104,7 @@
"CoreAudio_ThreadStampMessages=0",
"BGM_StopDebuggerOnLoggedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS)",
"BGM_StopDebuggerOnLoggedUnexpectedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS)",
"CoreAudio_StopOnThrow=1",
"CoreAudio_StopOnThrow=0",
);
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@ -1125,6 +1126,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-fno-omit-frame-pointer";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
WARNING_CFLAGS = "-Wpartial-availability";
@ -1156,6 +1158,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 1;
CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
@ -1199,7 +1202,7 @@
"CoreAudio_ThreadStampMessages=0",
"BGM_StopDebuggerOnLoggedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS)",
"BGM_StopDebuggerOnLoggedUnexpectedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS)",
"CoreAudio_StopOnThrow=1",
"CoreAudio_StopOnThrow=0",
);
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@ -1221,6 +1224,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-fno-omit-frame-pointer";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
WARNING_CFLAGS = "-Wpartial-availability";
@ -1233,6 +1237,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 0;
CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
@ -1294,6 +1299,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
WARNING_CFLAGS = "-Wpartial-availability";

View file

@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableAddressSanitizer = "YES">
<Testables>
<TestableReference
skipped = "NO">
@ -59,6 +60,7 @@
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
enableAddressSanitizer = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
@ -70,6 +72,13 @@
ReferencedContainer = "container:BGMApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "ASAN_OPTIONS"
value = "detect_odr_violation=1:use_odr_indicator=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:check_initialization_order=1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>

View file

@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableAddressSanitizer = "YES">
<Testables>
<TestableReference
skipped = "NO">
@ -85,7 +86,7 @@
<EnvironmentVariables>
<EnvironmentVariable
key = "ASAN_OPTIONS"
value = "detect_odr_violation=0,use_odr_indicator=1"
value = "detect_odr_violation=1:use_odr_indicator=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:check_initialization_order=1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>

View file

@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableAddressSanitizer = "YES">
<Testables>
<TestableReference
skipped = "NO">
@ -78,7 +79,7 @@
<EnvironmentVariables>
<EnvironmentVariable
key = "ASAN_OPTIONS"
value = "detect_odr_violation=0"
value = "detect_odr_violation=1:use_odr_indicator=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:check_initialization_order=1:log_to_syslog=1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>

View file

@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableAddressSanitizer = "YES">
<Testables>
</Testables>
<AdditionalOptions>
@ -51,6 +52,13 @@
ReferencedContainer = "container:BGMDriver.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "ASAN_OPTIONS"
value = "detect_odr_violation=1:use_odr_indicator=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:check_initialization_order=1:log_to_syslog=1"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>

View file

@ -621,8 +621,7 @@ echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to"
# Disable the -e shell option and error trap for build commands so we can handle errors differently.
(disable_error_handling
# Build Apple's PublicUtility classes as a static library.
${SUDO} "${XCODEBUILD}" -project BGMDriver/BGMDriver.xcodeproj \
-target "PublicUtility" \
${SUDO} "${XCODEBUILD}" -scheme "PublicUtility" \
-configuration ${CONFIGURATION} \
RUN_CLANG_STATIC_ANALYZER=0 \
${XCODEBUILD_OPTIONS} \
@ -630,9 +629,7 @@ echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to"
(disable_error_handling
# Build and install BGMDriver
# TODO: Should these use -scheme instead?
${SUDO} "${XCODEBUILD}" -project BGMDriver/BGMDriver.xcodeproj \
-target "Background Music Device" \
${SUDO} "${XCODEBUILD}" -scheme "Background Music Device" \
-configuration ${CONFIGURATION} \
RUN_CLANG_STATIC_ANALYZER=0 \
DSTROOT="/" \
@ -647,8 +644,7 @@ echo "[2/3] ${ACTIONING} $(bold_face ${XPC_HELPER_DIR}) to $(bold_face ${XPC_HEL
| tee -a ${LOG_FILE}
(disable_error_handling
${SUDO} "${XCODEBUILD}" -project BGMApp/BGMApp.xcodeproj \
-target BGMXPCHelper \
${SUDO} "${XCODEBUILD}" -scheme BGMXPCHelper \
-configuration ${CONFIGURATION} \
RUN_CLANG_STATIC_ANALYZER=0 \
DSTROOT="/" \
@ -664,8 +660,7 @@ echo "[3/3] ${ACTIONING} $(bold_face ${APP_DIR}) to $(bold_face ${APP_PATH})" \
| tee -a ${LOG_FILE}
(disable_error_handling
${SUDO} "${XCODEBUILD}" -project BGMApp/BGMApp.xcodeproj \
-target "Background Music" \
${SUDO} "${XCODEBUILD}" -scheme "Background Music" \
-configuration ${CONFIGURATION} \
RUN_CLANG_STATIC_ANALYZER=0 \
DSTROOT="/" \