[asan] Allow re-exec in instrumented unit tests on Darwin (fix unit tests on macOS...
authorKuba Mracek <mracek@apple.com>
Wed, 30 Nov 2016 00:46:04 +0000 (00:46 +0000)
committerKuba Mracek <mracek@apple.com>
Wed, 30 Nov 2016 00:46:04 +0000 (00:46 +0000)
This fixes https://llvm.org/bugs/show_bug.cgi?id=30285. On macOS 10.10 and lower, instrumented unit tests still need to be able to re-exec to make interceptors work.

Differential Revision: https://reviews.llvm.org/D24699

llvm-svn: 288224

compiler-rt/lib/asan/tests/asan_test_main.cc

index d4d6de7..1071d44 100644 (file)
@@ -28,9 +28,18 @@ extern "C" const char* __asan_default_options() {
 
 namespace __sanitizer {
 bool ReexecDisabled() {
+#if __has_feature(address_sanitizer) && SANITIZER_MAC
+  // Allow re-exec in instrumented unit tests on Darwin.  Technically, we only
+  // need this for 10.10 and below, where re-exec is required for the
+  // interceptors to work, but to avoid duplicating the version detection logic,
+  // let's just allow re-exec for all Darwin versions.  On newer OS versions,
+  // returning 'false' doesn't do anything anyway, because we don't re-exec.
+  return false;
+#else
   return true;
+#endif
 }
-}
+}  // namespace __sanitizer
 
 int main(int argc, char **argv) {
   testing::GTEST_FLAG(death_test_style) = "threadsafe";