Kevin submitted an exception handler found in a C++ codebase to The Daily WTF. It catches Exception::Deadlock and executes a single statement: retry. That is not a C++ keyword, so it must be a macro, most likely one wrapping a goto that jumps back to the top of the guarded block.
catch (Exception::Deadlock)
{
retry;
}The problem is fundamental. A deadlock means this thread waits on a resource held by another thread, which in turn waits on a resource held by this thread. Retrying only helps if the retry first releases the resources this thread holds, letting the other thread proceed. According to Kevin, this retry does no such thing. It simply jumps back up, holding everything, guaranteeing the same deadlock again.
The kicker: the codebase already suffered from a pile of deadlocks, so the company brought in a highly paid consultant to fix them by reordering access and tracing mutex usage. This handler is the result of that engagement. Kevin's verdict: it seems the consultant wanted to add some deadlocks of their own.
Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.