[compiler-rt] r204227 - tsan: fix large stack frame in deadlock detector
Dmitry Vyukov
dvyukov at google.com
Wed Mar 19 05:49:46 PDT 2014
Author: dvyukov
Date: Wed Mar 19 07:49:46 2014
New Revision: 204227
URL: http://llvm.org/viewvc/llvm-project?rev=204227&view=rev
Log:
tsan: fix large stack frame in deadlock detector
In member function 'virtual void __sanitizer::DD::MutexBeforeLock(__sanitizer::DDCallback*, __sanitizer::DDMutex*, bool)':
error: the frame size of 544 bytes is larger than 512 bytes [-Werror=frame-larger-than=]
The code is now [arguably] better as well.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc?rev=204227&r1=204226&r2=204227&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc Wed Mar 19 07:49:46 2014
@@ -54,6 +54,7 @@ struct DD : public DDetector {
DDReport *GetReport(DDCallback *cb);
void MutexEnsureID(DDLogicalThread *lt, DDMutex *m);
+ void ReportDeadlock(DDCallback *cb, DDMutex *m);
};
DDetector *DDetector::Create(const DDFlags *flags) {
@@ -109,28 +110,33 @@ void DD::MutexBeforeLock(DDCallback *cb,
if (dd.onLockBefore(<->dd, m->id)) {
// Actually add this edge now so that we have all the stack traces.
dd.addEdges(<->dd, m->id, cb->Unwind());
- uptr path[10];
- uptr len = dd.findPathToLock(<->dd, m->id, path, ARRAY_SIZE(path));
- CHECK_GT(len, 0U); // Hm.. cycle of 10 locks? I'd like to see that.
- CHECK_EQ(m->id, path[0]);
- lt->report_pending = true;
- DDReport *rep = <->rep;
- rep->n = len;
- for (uptr i = 0; i < len; i++) {
- uptr from = path[i];
- uptr to = path[(i + 1) % len];
- DDMutex *m0 = (DDMutex*)dd.getData(from);
- DDMutex *m1 = (DDMutex*)dd.getData(to);
-
- u32 stk_from = 0, stk_to = 0;
- dd.findEdge(from, to, &stk_from, &stk_to);
- // Printf("Edge: %zd=>%zd: %u/%u\n", from, to, stk_from, stk_to);
- rep->loop[i].thr_ctx = 0; // don't know
- rep->loop[i].mtx_ctx0 = m0->ctx;
- rep->loop[i].mtx_ctx1 = m1->ctx;
- rep->loop[i].stk[0] = stk_from;
- rep->loop[i].stk[1] = stk_to;
- }
+ ReportDeadlock(cb, m);
+ }
+}
+
+void DD::ReportDeadlock(DDCallback *cb, DDMutex *m) {
+ DDLogicalThread *lt = cb->lt;
+ uptr path[10];
+ uptr len = dd.findPathToLock(<->dd, m->id, path, ARRAY_SIZE(path));
+ CHECK_GT(len, 0U); // Hm.. cycle of 10 locks? I'd like to see that.
+ CHECK_EQ(m->id, path[0]);
+ lt->report_pending = true;
+ DDReport *rep = <->rep;
+ rep->n = len;
+ for (uptr i = 0; i < len; i++) {
+ uptr from = path[i];
+ uptr to = path[(i + 1) % len];
+ DDMutex *m0 = (DDMutex*)dd.getData(from);
+ DDMutex *m1 = (DDMutex*)dd.getData(to);
+
+ u32 stk_from = 0, stk_to = 0;
+ dd.findEdge(from, to, &stk_from, &stk_to);
+ // Printf("Edge: %zd=>%zd: %u/%u\n", from, to, stk_from, stk_to);
+ rep->loop[i].thr_ctx = 0; // don't know
+ rep->loop[i].mtx_ctx0 = m0->ctx;
+ rep->loop[i].mtx_ctx1 = m1->ctx;
+ rep->loop[i].stk[0] = stk_from;
+ rep->loop[i].stk[1] = stk_to;
}
}
More information about the llvm-commits
mailing list