diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2014-03-19 12:49:46 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2014-03-19 12:49:46 +0000 |
| commit | 17efa197bf1567ee7dfe0d85ba7fe218b9bba0bc (patch) | |
| tree | 3fa82e0cca49fa8e5e0957e6c3fe20ba20d300d7 | |
| parent | f9a7b46ec6d350c77857d0c982c7c44878693f61 (diff) | |
| download | bcm5719-llvm-17efa197bf1567ee7dfe0d85ba7fe218b9bba0bc.tar.gz bcm5719-llvm-17efa197bf1567ee7dfe0d85ba7fe218b9bba0bc.zip | |
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
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc b/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc index 0e920d8a675..f936af6090e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cc @@ -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; } } |

