Locking: pre-emptively detect deadlocks in Lockvoker constructor
We can now check for deadlocks both pre-emptively and reactively. We can eventually add function vaddrs and even function names to our tracing code.
This commit is contained in:
@@ -72,6 +72,15 @@ public:
|
|||||||
target(target),
|
target(target),
|
||||||
invocationTarget(std::move(invocationTarget))
|
invocationTarget(std::move(invocationTarget))
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||||
|
if (traceContinuationHistoryForDeadlock())
|
||||||
|
{
|
||||||
|
handleDeadlock();
|
||||||
|
throw std::runtime_error(
|
||||||
|
"LockerAndInvoker::LockerAndInvoker(): Deadlock detected");
|
||||||
|
}
|
||||||
|
#endif // CONFIG_ENABLE_DEBUG_LOCKS
|
||||||
|
|
||||||
firstWake();
|
firstWake();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +204,20 @@ public:
|
|||||||
|
|
||||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||||
bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex);
|
bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex);
|
||||||
|
bool traceContinuationHistoryForDeadlock(void)
|
||||||
|
{
|
||||||
|
for (auto& lockUsageDesc
|
||||||
|
: serializedContinuation.requiredLocks.locks)
|
||||||
|
{
|
||||||
|
if (traceContinuationHistoryForDeadlockOn(
|
||||||
|
lockUsageDesc.first.get()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle a likely deadlock situation by logging debug information
|
* @brief Handle a likely deadlock situation by logging debug information
|
||||||
* @param firstFailedQutex The first qutex that failed acquisition
|
* @param firstFailedQutex The first qutex that failed acquisition
|
||||||
|
|||||||
Reference in New Issue
Block a user