CodeSOD: Lock 'Em Dead Note

CodeSOD: Lock 'Em Dead

The provided C++ code snippet shows an exception handler for a Deadlock exception. Upon catching this exception, the code attempts to retry. However, retry is not a standard C++ keyword and is likely a macro. The author suspects this macro is implemented using a goto statement.The core issue lies in the assumption that retry will resolve the deadlock. A deadlock occurs when two or more threads are blocked indefinitely, each waiting for a resource held by another. For retry to be effective, it would need to release the resource currently held by the deadlocked thread.According to Kevin, the author of the code, the retry macro does not release any resources. Instead, it simply jumps back to the beginning of the catch block. This means the thread remains stuck in the deadlock situation.Kevin points out that the system already suffered from numerous deadlocks. A consultant was hired to address these issues by reordering resource access and identifying mutex-related problems. The consultant's implementation of retry appears to have inadvertently introduced more deadlocks. Kevin humorously suggests the consultant might have intended to add their own deadlocks.