mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
merge bitcoin#19353: Fix mistakenly swapped "previous" and "current" lock orders
This commit is contained in:
parent
790a4f9d60
commit
2b48a6d6a2
30
src/sync.cpp
30
src/sync.cpp
@ -62,7 +62,7 @@ struct CLockLocation {
|
|||||||
std::string ToString() const
|
std::string ToString() const
|
||||||
{
|
{
|
||||||
return tfm::format(
|
return tfm::format(
|
||||||
"%s %s:%s%s (in thread %s)",
|
"'%s' in %s:%s%s (in thread '%s')",
|
||||||
mutexName, sourceFile, itostr(sourceLine), (fTry ? " (TRY)" : ""), m_thread_name);
|
mutexName, sourceFile, itostr(sourceLine), (fTry ? " (TRY)" : ""), m_thread_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,16 +108,6 @@ static void potential_deadlock_detected(const LockPair& mismatch, const LockStac
|
|||||||
std::string strOutput = "";
|
std::string strOutput = "";
|
||||||
strOutput += "POTENTIAL DEADLOCK DETECTED\n";
|
strOutput += "POTENTIAL DEADLOCK DETECTED\n";
|
||||||
strOutput += "Previous lock order was:\n";
|
strOutput += "Previous lock order was:\n";
|
||||||
for (const LockStackItem& i : s2) {
|
|
||||||
if (i.first == mismatch.first) {
|
|
||||||
strOutput += " (1)";
|
|
||||||
}
|
|
||||||
if (i.first == mismatch.second) {
|
|
||||||
strOutput += " (2)";
|
|
||||||
}
|
|
||||||
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
|
||||||
}
|
|
||||||
strOutput += "Current lock order is:\n";
|
|
||||||
for (const LockStackItem& i : s1) {
|
for (const LockStackItem& i : s1) {
|
||||||
if (i.first == mismatch.first) {
|
if (i.first == mismatch.first) {
|
||||||
strOutput += " (1)";
|
strOutput += " (1)";
|
||||||
@ -128,14 +118,28 @@ static void potential_deadlock_detected(const LockPair& mismatch, const LockStac
|
|||||||
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string mutex_a, mutex_b;
|
||||||
|
strOutput += "Current lock order is:\n";
|
||||||
|
for (const LockStackItem& i : s2) {
|
||||||
|
if (i.first == mismatch.first) {
|
||||||
|
strOutput += " (1)";
|
||||||
|
mutex_a = i.second.Name();
|
||||||
|
}
|
||||||
|
if (i.first == mismatch.second) {
|
||||||
|
strOutput += " (2)";
|
||||||
|
mutex_b = i.second.Name();
|
||||||
|
}
|
||||||
|
strOutput += strprintf(" %s\n", i.second.ToString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s\n", strOutput.c_str());
|
printf("%s\n", strOutput.c_str());
|
||||||
LogPrintf("%s\n", strOutput.c_str());
|
LogPrintf("%s\n", strOutput.c_str());
|
||||||
|
|
||||||
if (g_debug_lockorder_abort) {
|
if (g_debug_lockorder_abort) {
|
||||||
fprintf(stderr, "Assertion failed: detected inconsistent lock order at %s:%i, details in debug log.\n", __FILE__, __LINE__);
|
fprintf(stderr, "Assertion failed: detected inconsistent lock order for %s, details in debug log.\n", s2.back().second.ToString().c_str());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
throw std::logic_error("potential deadlock detected");
|
throw std::logic_error(strprintf("potential deadlock detected: %s -> %s -> %s", mutex_b, mutex_a, mutex_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void push_lock(void* c, const CLockLocation& locklocation)
|
static void push_lock(void* c, const CLockLocation& locklocation)
|
||||||
|
@ -19,7 +19,7 @@ void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
|
|||||||
try {
|
try {
|
||||||
LOCK2(mutex2, mutex1);
|
LOCK2(mutex2, mutex1);
|
||||||
} catch (const std::logic_error& e) {
|
} catch (const std::logic_error& e) {
|
||||||
BOOST_CHECK_EQUAL(e.what(), "potential deadlock detected");
|
BOOST_CHECK_EQUAL(e.what(), "potential deadlock detected: mutex1 -> mutex2 -> mutex1");
|
||||||
error_thrown = true;
|
error_thrown = true;
|
||||||
}
|
}
|
||||||
BOOST_CHECK(LockStackEmpty());
|
BOOST_CHECK(LockStackEmpty());
|
||||||
|
Loading…
Reference in New Issue
Block a user