forked from OSchip/llvm-project
[sanitizer] Break infinite recursion in case of recursive failed CHECKs
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. Differential Revision: http://reviews.llvm.org/D20047 llvm-svn: 269288
This commit is contained in:
parent
cf6a78192b
commit
e0c8256781
|
@ -153,8 +153,16 @@ void SetCheckFailedCallback(CheckFailedCallbackType callback) {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue