[PATCH] D20047: [sanitizer] Break infinite recursion in case of recursive failed CHECKs

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 05:56:00 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL269288: [sanitizer] Break infinite recursion in case of recursive failed CHECKs (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D20047?vs=56495&id=57024#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20047

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc

Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
@@ -153,8 +153,16 @@
   CheckFailedCallback = callback;
 }
 
+const int kSecondsToSleepWhenRecursiveCheckFailed = 2;
+
 void NORETURN CheckFailed(const char *file, int line, const char *cond,
                           u64 v1, u64 v2) {
+  static atomic_uint32_t num_calls;
+  if (atomic_fetch_add(&num_calls, 1, memory_order_relaxed) > 10) {
+    SleepForSeconds(kSecondsToSleepWhenRecursiveCheckFailed);
+    Trap();
+  }
+
   if (CheckFailedCallback) {
     CheckFailedCallback(file, line, cond, v1, v2);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20047.57024.patch
Type: text/x-patch
Size: 773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160512/43ea2efe/attachment.bin>


More information about the llvm-commits mailing list