sanitizer_common: use 0 for empty stack id
authorDmitry Vyukov <dvyukov@google.com>
Sun, 11 Jul 2021 12:46:09 +0000 (14:46 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Mon, 12 Jul 2021 10:24:27 +0000 (12:24 +0200)
We use 0 for empty stack id from stack depot.
Deadlock detector 1 is the only place that uses -1
as a special case. Use 0 because there is a number
of checks of the form "if (stack id) ...".

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D105776

compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector1.cpp

index 2c924f5d3963919fa2c9034ea3f1e594a1c46c20..ccb7065b07aed961e367c0ada403fdc5d927d0fd 100644 (file)
@@ -136,7 +136,7 @@ void DD::ReportDeadlock(DDCallback *cb, DDMutex *m) {
     DDMutex *m0 = (DDMutex*)dd.getData(from);
     DDMutex *m1 = (DDMutex*)dd.getData(to);
 
-    u32 stk_from = -1U, stk_to = -1U;
+    u32 stk_from = 0, stk_to = 0;
     int unique_tid = 0;
     dd.findEdge(from, to, &stk_from, &stk_to, &unique_tid);
     // Printf("Edge: %zd=>%zd: %u/%u T%d\n", from, to, stk_from, stk_to,