diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-11-30 17:45:53 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-11-30 17:45:53 +0000 |
commit | 543b94a5cd102c0795b44d78234d5458eed2c75e (patch) | |
tree | 71df0f578a4b44be3466a23b999bd5fec4669f71 /lib/tsan/rtl/tsan_rtl_report.cc | |
parent | 07ba8ef44deb54baa9307298fbffe25ddb30c362 (diff) | |
download | compiler-rt-543b94a5cd102c0795b44d78234d5458eed2c75e.tar.gz compiler-rt-543b94a5cd102c0795b44d78234d5458eed2c75e.tar.bz2 compiler-rt-543b94a5cd102c0795b44d78234d5458eed2c75e.tar.xz |
tsan: suppress weird race reports when JVM is embed into the process
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169019 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_rtl_report.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_rtl_report.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cc index d622c4d8..7ba9e584 100644 --- a/lib/tsan/rtl/tsan_rtl_report.cc +++ b/lib/tsan/rtl/tsan_rtl_report.cc @@ -385,6 +385,39 @@ bool IsFiredSuppression(Context *ctx, return false; } +// On programs that use Java we see weird reports like: +// WARNING: ThreadSanitizer: data race (pid=22512) +// Read of size 8 at 0x7d2b00084318 by thread 100: +// #0 memcpy tsan_interceptors.cc:406 (foo+0x00000d8dfae3) +// #1 <null> <null>:0 (0x7f7ad9b40193) +// Previous write of size 8 at 0x7d2b00084318 by thread 105: +// #0 strncpy tsan_interceptors.cc:501 (foo+0x00000d8e0919) +// #1 <null> <null>:0 (0x7f7ad9b42707) +static bool IsJavaNonsense(const ReportDesc *rep) { + for (uptr i = 0; i < rep->mops.Size(); i++) { + ReportMop *mop = rep->mops[i]; + ReportStack *frame = mop->stack; + if (frame != 0 && frame->func != 0 + && (internal_strcmp(frame->func, "memset") == 0 + || internal_strcmp(frame->func, "memcpy") == 0 + || internal_strcmp(frame->func, "strcmp") == 0 + || internal_strcmp(frame->func, "strncpy") == 0 + || internal_strcmp(frame->func, "pthread_mutex_lock") == 0)) { + frame = frame->next; + if (frame == 0 + || (frame->func == 0 && frame->file == 0 && frame->line == 0 + && frame->module == 0)) { + if (frame) { + FiredSuppression supp = {rep->typ, frame->pc}; + CTX()->fired_suppressions.PushBack(supp); + } + return true; + } + } + } + return false; +} + void ReportRace(ThreadState *thr) { if (!flags()->report_bugs) return; @@ -432,6 +465,9 @@ void ReportRace(ThreadState *thr) { rep.AddMemoryAccess(addr, s, &traces[i]); } + if (flags()->suppress_java && IsJavaNonsense(rep.GetReport())) + return; + for (uptr i = 0; i < kMop; i++) { FastState s(thr->racy_state[i]); ThreadContext *tctx = ctx->threads[s.tid()]; |