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. llvm-svn: 204227
This commit is contained in:
parent
f9a7b46ec6
commit
17efa197bf
|
@ -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);
|
||||
ReportDeadlock(cb, m);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue