@@ -77,52 +77,28 @@ boost::thread_specific_ptr<LockStack> lockstack;
77
77
78
78
static void potential_deadlock_detected (const std::pair<void *, void *>& mismatch, const LockStack& s1, const LockStack& s2)
79
79
{
80
- // We attempt to not assert on probably-not deadlocks by assuming that
81
- // a try lock will immediately have otherwise bailed if it had
82
- // failed to get the lock
83
- // We do this by, for the locks which triggered the potential deadlock,
84
- // in either lockorder, checking that the second of the two which is locked
85
- // is only a TRY_LOCK, ignoring locks if they are reentrant.
86
- bool firstLocked = false ;
87
- bool secondLocked = false ;
88
- bool onlyMaybeDeadlock = false ;
89
-
90
80
LogPrintf (" POTENTIAL DEADLOCK DETECTED\n " );
91
81
LogPrintf (" Previous lock order was:\n " );
92
82
BOOST_FOREACH (const PAIRTYPE (void *, CLockLocation) & i, s2) {
93
83
if (i.first == mismatch.first ) {
94
84
LogPrintf (" (1)" );
95
- if (!firstLocked && secondLocked && i.second .fTry )
96
- onlyMaybeDeadlock = true ;
97
- firstLocked = true ;
98
85
}
99
86
if (i.first == mismatch.second ) {
100
87
LogPrintf (" (2)" );
101
- if (!secondLocked && firstLocked && i.second .fTry )
102
- onlyMaybeDeadlock = true ;
103
- secondLocked = true ;
104
88
}
105
89
LogPrintf (" %s\n " , i.second .ToString ());
106
90
}
107
- firstLocked = false ;
108
- secondLocked = false ;
109
91
LogPrintf (" Current lock order is:\n " );
110
92
BOOST_FOREACH (const PAIRTYPE (void *, CLockLocation) & i, s1) {
111
93
if (i.first == mismatch.first ) {
112
94
LogPrintf (" (1)" );
113
- if (!firstLocked && secondLocked && i.second .fTry )
114
- onlyMaybeDeadlock = true ;
115
- firstLocked = true ;
116
95
}
117
96
if (i.first == mismatch.second ) {
118
97
LogPrintf (" (2)" );
119
- if (!secondLocked && firstLocked && i.second .fTry )
120
- onlyMaybeDeadlock = true ;
121
- secondLocked = true ;
122
98
}
123
99
LogPrintf (" %s\n " , i.second .ToString ());
124
100
}
125
- assert (onlyMaybeDeadlock );
101
+ assert (false );
126
102
}
127
103
128
104
static void push_lock (void * c, const CLockLocation& locklocation, bool fTry )
@@ -134,21 +110,19 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
134
110
135
111
(*lockstack).push_back (std::make_pair (c, locklocation));
136
112
137
- if (!fTry ) {
138
- BOOST_FOREACH (const PAIRTYPE (void *, CLockLocation) & i, (*lockstack)) {
139
- if (i.first == c)
140
- break ;
113
+ BOOST_FOREACH (const PAIRTYPE (void *, CLockLocation) & i, (*lockstack)) {
114
+ if (i.first == c)
115
+ break ;
141
116
142
- std::pair<void *, void *> p1 = std::make_pair (i.first , c);
143
- if (lockdata.lockorders .count (p1))
144
- continue ;
145
- lockdata.lockorders [p1] = (*lockstack);
117
+ std::pair<void *, void *> p1 = std::make_pair (i.first , c);
118
+ if (lockdata.lockorders .count (p1))
119
+ continue ;
120
+ lockdata.lockorders [p1] = (*lockstack);
146
121
147
- std::pair<void *, void *> p2 = std::make_pair (c, i.first );
148
- lockdata.invlockorders .insert (p2);
149
- if (lockdata.lockorders .count (p2))
150
- potential_deadlock_detected (p1, lockdata.lockorders [p2], lockdata.lockorders [p1]);
151
- }
122
+ std::pair<void *, void *> p2 = std::make_pair (c, i.first );
123
+ lockdata.invlockorders .insert (p2);
124
+ if (lockdata.lockorders .count (p2))
125
+ potential_deadlock_detected (p1, lockdata.lockorders [p2], lockdata.lockorders [p1]);
152
126
}
153
127
}
154
128
0 commit comments