Skip to content

Commit 8465631

Browse files
committed
Always enforce lock strict lock ordering (try or not)
1 parent fd13eca commit 8465631

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/sync.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,52 +77,28 @@ boost::thread_specific_ptr<LockStack> lockstack;
7777

7878
static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, const LockStack& s1, const LockStack& s2)
7979
{
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-
9080
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
9181
LogPrintf("Previous lock order was:\n");
9282
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) {
9383
if (i.first == mismatch.first) {
9484
LogPrintf(" (1)");
95-
if (!firstLocked && secondLocked && i.second.fTry)
96-
onlyMaybeDeadlock = true;
97-
firstLocked = true;
9885
}
9986
if (i.first == mismatch.second) {
10087
LogPrintf(" (2)");
101-
if (!secondLocked && firstLocked && i.second.fTry)
102-
onlyMaybeDeadlock = true;
103-
secondLocked = true;
10488
}
10589
LogPrintf(" %s\n", i.second.ToString());
10690
}
107-
firstLocked = false;
108-
secondLocked = false;
10991
LogPrintf("Current lock order is:\n");
11092
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) {
11193
if (i.first == mismatch.first) {
11294
LogPrintf(" (1)");
113-
if (!firstLocked && secondLocked && i.second.fTry)
114-
onlyMaybeDeadlock = true;
115-
firstLocked = true;
11695
}
11796
if (i.first == mismatch.second) {
11897
LogPrintf(" (2)");
119-
if (!secondLocked && firstLocked && i.second.fTry)
120-
onlyMaybeDeadlock = true;
121-
secondLocked = true;
12298
}
12399
LogPrintf(" %s\n", i.second.ToString());
124100
}
125-
assert(onlyMaybeDeadlock);
101+
assert(false);
126102
}
127103

128104
static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)

0 commit comments

Comments
 (0)