From 3a50be05f8017469e43046091fece759fa338abc Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 4 Oct 2025 14:48:38 -0400 Subject: [PATCH] Qutex: nRequiredLocks==1 at front should never call backoff --- smocore/qutex.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/smocore/qutex.cpp b/smocore/qutex.cpp index 3fe5c88..967fe73 100644 --- a/smocore/qutex.cpp +++ b/smocore/qutex.cpp @@ -123,8 +123,25 @@ void Qutex::backoff( ": backoff called on empty queue - this should never happen"); } + /* Check if failedAcquirer is at the front of the queue with + * nRequiredLocks == 1. This should never happen because an + * acquirer at the front of the queue with nRequiredLocks == 1 + * should always succeed. + */ + const LockerAndInvokerBase& oldFront = *queue.front(); + if (oldFront == failedAcquirer && nRequiredLocks == 1) + { + lock.release(); + + throw std::runtime_error( + std::string(__func__) + + ": Failed acquirer is at front of queue with nRequiredLocks==1 - " + "acquirer at front of queue with nRequiredLocks==1 should always " + "succeed."); + } + // Rotate queue members if failedAcquirer is at front of queue - if ((*queue.front()) == failedAcquirer && nQItems > 1) + if (oldFront == failedAcquirer && nQItems > 1) { /** EXPLANATION: * Rotate the top LockSet.size() items in the queue by moving