[Sanitizers] Re-apply the fix ordering initialization of coverage and guard arrays
authorViktor Kutuzov <vkutuzov@accesssoftek.com>
Mon, 2 Feb 2015 09:38:10 +0000 (09:38 +0000)
committerViktor Kutuzov <vkutuzov@accesssoftek.com>
Mon, 2 Feb 2015 09:38:10 +0000 (09:38 +0000)
Original commit: http://reviews.llvm.org/rL226440
Related review: http://reviews.llvm.org/D6892

llvm-svn: 227789

compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc

index 71f7bd4..9414bcb 100644 (file)
@@ -157,7 +157,8 @@ void CoverageData::Init() {
 }
 
 void CoverageData::Enable() {
-  CHECK_EQ(pc_array, nullptr);
+  if (pc_array)
+    return;
   pc_array = reinterpret_cast<uptr *>(
       MmapNoReserveOrDie(sizeof(uptr) * kPcArrayMaxSize, "CovInit"));
   atomic_store(&pc_array_index, 0, memory_order_relaxed);
@@ -183,6 +184,7 @@ void CoverageData::Enable() {
 }
 
 void CoverageData::InitializeGuardArray(s32 *guards) {
+  Enable();  // Make sure coverage is enabled at this point.
   s32 n = guards[0];
   for (s32 j = 1; j <= n; j++) {
     uptr idx = atomic_fetch_add(&pc_array_index, 1, memory_order_relaxed);