[PATCH] [Sanitizers] Order initialization of coverage and guard arrays

Viktor Kutuzov vkutuzov at accesssoftek.com
Fri Jan 16 06:47:55 PST 2015


Updated.


http://reviews.llvm.org/D6892

Files:
  lib/sanitizer_common/sanitizer_coverage_libcdep.cc

Index: lib/sanitizer_common/sanitizer_coverage_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_coverage_libcdep.cc
+++ lib/sanitizer_common/sanitizer_coverage_libcdep.cc
@@ -156,7 +156,8 @@
 }
 
 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);
@@ -182,6 +183,7 @@
 }
 
 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);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6892.18301.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150116/083bd00a/attachment.bin>


More information about the llvm-commits mailing list