[PATCH] D20047: [sanitizer] Break infinite recursion in case of recursive failed CHECKs
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Sat May 7 07:34:01 PDT 2016
kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, samsonov, glider, kcc, aizatsky.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.
kubabrecka added a project: Sanitizers.
Herald added a subscriber: kubabrecka.
While debugging ASan and TSan, I sometimes get a recursion during a failed CHECK processing. `CheckFailed` can call a lot of code (printing, unwinding a stack trace, symbolicating, ...) and this can fail another CHECK. This means I sometimes see a crash due to a infinite recursion stack overflow. Let's stop after 10 failed CHECKs and just kill the process immediately. I also added a `Sleep(2)` call before the trap, so that other threads still get a chance to print their failed CHECKs.
http://reviews.llvm.org/D20047
Files:
lib/sanitizer_common/sanitizer_common.cc
Index: lib/sanitizer_common/sanitizer_common.cc
===================================================================
--- lib/sanitizer_common/sanitizer_common.cc
+++ 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.56495.patch
Type: text/x-patch
Size: 719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160507/47d41225/attachment.bin>
More information about the llvm-commits
mailing list