Leaked Concurrency Handle (ARCH6085)
Key ruby.performance.leaked-concurrency-handle · Severity warning · Category performance
A lock acquired with lock and held without the block form is never released if an exception is raised, causing a deadlock. Manage the lock with the block form.
Incorrect
Section titled “Incorrect”def increment(mutex, counter) mutex.lock counter.value += 1 mutex.unlockendCorrect
Section titled “Correct”def increment(mutex, counter) mutex.synchronize do counter.value += 1 endendAcquire locks with the synchronize block form; start threads with a bounded lifetime and join them.