Skip to content

Commit a4fe57d

Browse files
committed
Revert "Assert on probable deadlocks if the second lock isnt try_lock"
Disabling this for now - too many intermittent Travis issues. This reverts commit 0fcc4e1 (pull #5515).
1 parent 2f746c6 commit a4fe57d

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

src/sync.cpp

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,20 @@ void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
3333
//
3434

3535
struct CLockLocation {
36-
CLockLocation(const char* pszName, const char* pszFile, int nLine, bool fTryIn)
36+
CLockLocation(const char* pszName, const char* pszFile, int nLine)
3737
{
3838
mutexName = pszName;
3939
sourceFile = pszFile;
4040
sourceLine = nLine;
41-
fTry = fTryIn;
4241
}
4342

4443
std::string ToString() const
4544
{
46-
return mutexName + " " + sourceFile + ":" + itostr(sourceLine) + (fTry ? " (TRY)" : "");
45+
return mutexName + " " + sourceFile + ":" + itostr(sourceLine);
4746
}
4847

4948
std::string MutexName() const { return mutexName; }
5049

51-
bool fTry;
5250
private:
5351
std::string mutexName;
5452
std::string sourceFile;
@@ -64,52 +62,23 @@ static boost::thread_specific_ptr<LockStack> lockstack;
6462

6563
static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, const LockStack& s1, const LockStack& s2)
6664
{
67-
// We attempt to not assert on probably-not deadlocks by assuming that
68-
// a try lock will immediately have otherwise bailed if it had
69-
// failed to get the lock
70-
// We do this by, for the locks which triggered the potential deadlock,
71-
// in either lockorder, checking that the second of the two which is locked
72-
// is only a TRY_LOCK, ignoring locks if they are reentrant.
73-
bool firstLocked = false;
74-
bool secondLocked = false;
75-
bool onlyMaybeDeadlock = false;
76-
7765
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
7866
LogPrintf("Previous lock order was:\n");
7967
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) {
80-
if (i.first == mismatch.first) {
68+
if (i.first == mismatch.first)
8169
LogPrintf(" (1)");
82-
if (!firstLocked && secondLocked && i.second.fTry)
83-
onlyMaybeDeadlock = true;
84-
firstLocked = true;
85-
}
86-
if (i.first == mismatch.second) {
70+
if (i.first == mismatch.second)
8771
LogPrintf(" (2)");
88-
if (!secondLocked && firstLocked && i.second.fTry)
89-
onlyMaybeDeadlock = true;
90-
secondLocked = true;
91-
}
9272
LogPrintf(" %s\n", i.second.ToString());
9373
}
94-
firstLocked = false;
95-
secondLocked = false;
9674
LogPrintf("Current lock order is:\n");
9775
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) {
98-
if (i.first == mismatch.first) {
76+
if (i.first == mismatch.first)
9977
LogPrintf(" (1)");
100-
if (!firstLocked && secondLocked && i.second.fTry)
101-
onlyMaybeDeadlock = true;
102-
firstLocked = true;
103-
}
104-
if (i.first == mismatch.second) {
78+
if (i.first == mismatch.second)
10579
LogPrintf(" (2)");
106-
if (!secondLocked && firstLocked && i.second.fTry)
107-
onlyMaybeDeadlock = true;
108-
secondLocked = true;
109-
}
11080
LogPrintf(" %s\n", i.second.ToString());
11181
}
112-
assert(onlyMaybeDeadlock);
11382
}
11483

11584
static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
@@ -132,8 +101,10 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
132101
lockorders[p1] = (*lockstack);
133102

134103
std::pair<void*, void*> p2 = std::make_pair(c, i.first);
135-
if (lockorders.count(p2))
104+
if (lockorders.count(p2)) {
136105
potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
106+
break;
107+
}
137108
}
138109
}
139110
dd_mutex.unlock();
@@ -148,7 +119,7 @@ static void pop_lock()
148119

149120
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry)
150121
{
151-
push_lock(cs, CLockLocation(pszName, pszFile, nLine, fTry), fTry);
122+
push_lock(cs, CLockLocation(pszName, pszFile, nLine), fTry);
152123
}
153124

154125
void LeaveCritical()

0 commit comments

Comments
 (0)