Document xcode config settings to enable Clang Sanitizers

Originator:steipete
Number:rdar://28250805 Date Originated:11-Sep-2016 09:35 PM
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
Summary:
Here's what I gobbled together based on Google; mostly thanks to WebKit being open source. (I only tested CLANG_ADDRESS_SANITIZER so far, but based on Google the other flags should work as well)

// AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library.
// Typical slowdown introduced by AddressSanitizer is 2x.
// http://clang.llvm.org/docs/AddressSanitizer.html
CLANG_ADDRESS_SANITIZER = YES

// ThreadSanitizer is a tool that detects data races. It consists of a compiler instrumentation module and a run-time library.
// Typical slowdown introduced by ThreadSanitizer is about 5x-15x. Typical memory overhead introduced by ThreadSanitizer is about 5x-10x.
// http://clang.llvm.org/docs/ThreadSanitizer.html
CLANG_THREAD_SANITIZER = NO

// MemorySanitizer is a detector of uninitialized reads. It consists of a compiler instrumentation module and a run-time library.
// Typical slowdown introduced by MemorySanitizer is 3x.
// http://clang.llvm.org/docs/MemorySanitizer.html
CLANG_MEMORY_SANITIZER = NO

Please document this.

Comments

| CLANG_ADDRESS_SANITIZER = YES

The official variable name is: ENABLE_ADDRESS_SANITIZER

| CLANG_THREAD_SANITIZER = NO

The official variable name is: ENABLE_THREAD_SANITIZER

| CLANG_MEMORY_SANITIZER = NO

MemorySanitizer (MSan) is not currently supported in clang that ships with Xcode.

Note: You can only use one Sanitizer per run, do not try to combine them!


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!