Bug 1335446 - Add allocator_may_return_null=1 to default ASan options. r?glandium draft
authorChristian Holler <choller@mozilla.com>
Mon, 06 Feb 2017 14:23:55 +0100
changeset 479316 19c8c086c7c6b04f5c8650bfaeef22a60515a900
parent 468498 ee975d32deb9eaa5641f45428cd6a4b5b555a8f5
child 544655 1c9086dd61580fa4384a162fa5aee0b89cf166ba
push id44220
push usercholler@mozilla.com
push dateMon, 06 Feb 2017 13:39:30 +0000
reviewersglandium
bugs1335446
milestone54.0a1
Bug 1335446 - Add allocator_may_return_null=1 to default ASan options. r?glandium MozReview-Commit-ID: AM9EdKngmMB
mozglue/build/AsanOptions.cpp
--- a/mozglue/build/AsanOptions.cpp
+++ b/mozglue/build/AsanOptions.cpp
@@ -22,14 +22,20 @@
 //   while the other doesn't, ASan will report false positives.
 //
 //   detect_leaks=0 - Disable LeakSanitizer. This is required because
 //   otherwise leak checking will be enabled for various building and
 //   testing executables where we don't care much about leaks. Enabling
 //   this will also likely require setting LSAN_OPTIONS with a suppression
 //   file, as in build/sanitizers/lsan_suppressions.txt.
 //
+//   allocator_may_return_null=1 - Tell ASan to return NULL when an allocation
+//   fails instead of aborting the program. This allows us to handle failing
+//   allocations the same way we would handle them with a regular allocator and
+//   also uncovers potential bugs that might occur in these situations.
+//
 extern "C" MOZ_ASAN_BLACKLIST
 const char* __asan_default_options() {
-    return "allow_user_segv_handler=1:alloc_dealloc_mismatch=0:detect_leaks=0";
+    return "allow_user_segv_handler=1:alloc_dealloc_mismatch=0:detect_leaks=0"
+           ":allocator_may_return_null=1";
 }
 
 #endif