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

Viktor Kutuzov vkutuzov at accesssoftek.com
Fri Jan 9 05:01:52 PST 2015


Hi kcc, samsonov,

Since there's no guarantee the first InitializeGuardArray() call comes after Init(), we have to make sure the coverage is initialized before we add a guard array.

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
@@ -150,7 +150,8 @@
 }
 
 void CoverageData::Init() {
-  CHECK_EQ(pc_array, nullptr);
+  if (pc_array)
+    return;
   pc_array = reinterpret_cast<uptr *>(
       MmapNoReserveOrDie(sizeof(uptr) * kPcArrayMaxSize, "CovInit"));
   pc_fd = kInvalidFd;
@@ -177,6 +178,8 @@
 }
 
 void CoverageData::InitializeGuardArray(s32 *guards) {
+  if (!pc_array)
+    Init();
   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.17924.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150109/c3f605b7/attachment.bin>


More information about the llvm-commits mailing list