[compiler-rt] r288224 - [asan] Allow re-exec in instrumented unit tests on Darwin (fix unit tests on macOS <=10.10)

Kuba Mracek via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 16:46:04 PST 2016


Author: kuba.brecka
Date: Tue Nov 29 18:46:04 2016
New Revision: 288224

URL: http://llvm.org/viewvc/llvm-project?rev=288224&view=rev
Log:
[asan] Allow re-exec in instrumented unit tests on Darwin (fix unit tests on macOS <=10.10)

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


Modified:
    compiler-rt/trunk/lib/asan/tests/asan_test_main.cc

Modified: compiler-rt/trunk/lib/asan/tests/asan_test_main.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test_main.cc?rev=288224&r1=288223&r2=288224&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test_main.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test_main.cc Tue Nov 29 18:46:04 2016
@@ -28,9 +28,18 @@ extern "C" const char* __asan_default_op
 
 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";




More information about the llvm-commits mailing list