{"id":16079,"date":"2016-10-17T14:47:03","date_gmt":"2016-10-17T18:47:03","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=16079"},"modified":"2017-02-18T19:33:04","modified_gmt":"2017-02-19T00:33:04","slug":"undocumented-xcode-sanitizer-settings","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/10\/17\/undocumented-xcode-sanitizer-settings\/","title":{"rendered":"Undocumented Xcode Sanitizer Settings"},"content":{"rendered":"<p><a href=\"https:\/\/openradar.appspot.com\/28250805\">Peter Steinberger<\/a> (<a href=\"https:\/\/twitter.com\/steipete\/status\/775067118735880192\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/openradar.appspot.com\/28250805\"><p>Here&rsquo;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).<\/p><\/blockquote>\n<p>There are also <code>CLANG_THREAD_SANITIZER<\/code> and <code>CLANG_MEMORY_SANITIZER<\/code>. The <a href=\"https:\/\/pspdfkit.com\/blog\/2016\/test-with-asan\/\">address sanitizer<\/a> seems most useful, though:<\/p>\n<blockquote cite=\"https:\/\/pspdfkit.com\/blog\/2016\/test-with-asan\/\">\n<p>Since this flag is undocumented it might change without warning, and there are some hints that this might be renamed to <code>ENABLE_ADDRESS_SANITIZER<\/code>.<\/p>\n<p>Using this flag makes it simpler to dynamically switch this on or off without having to create a separate Xcode configuration that would be much harder to maintain, and you can configure your CI to run tests both with and without ASan to both have a great assurance of memory correctness and testing the binary that you actually ship to customers.<\/p><\/blockquote>\n<p>Update (2017-02-18): <a href=\"https:\/\/twitter.com\/steipete\/status\/832533928753975296\">Peter Steinberger<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/steipete\/status\/832533928753975296\"><p>The ASAN_OPTIONS hack is no longer needed, this now works as expected in Xcode 8.2+<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Peter Steinberger (tweet): Here&rsquo;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). There are also CLANG_THREAD_SANITIZER and CLANG_MEMORY_SANITIZER. The address sanitizer seems most useful, though: Since this flag is undocumented it might [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[56,164,30,1381,71,226],"class_list":["post-16079","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-debugging","tag-documentation","tag-mac","tag-macos-10-12","tag-programming","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=16079"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16079\/revisions"}],"predecessor-version":[{"id":17246,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/16079\/revisions\/17246"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=16079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=16079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=16079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}