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:
2025-09-27 21:27:04 -04:00
parent f8bf8083af
commit 2f18ade4ab
@@ -72,6 +72,15 @@ public:
target(target),
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();
}
@@ -195,6 +204,20 @@ public:
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
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
* @param firstFailedQutex The first qutex that failed acquisition