| Previous | Next |
| ERANGE | EAGAIN |
EDEADLK
A deadlock warning from the lock subsystem
EDEADLK means that the locking subsystem detected a request that would create a deadlock cycle. It can arise from blocking POSIX record-lock operations, and related lock APIs may use it when a thread tries to acquire a non-recursive mutex it already owns. The result is valuable because the caller is still running; it can release resources, report the lock graph, and choose a recovery path instead of waiting forever.
Detection is not universal. A program can still deadlock through locks in different processes, library layers, RPC calls, or resources that the kernel cannot relate. Treat this errno as evidence of a lock-order design problem, not as a condition to suppress with an immediate retry.
How to investigate
- Record every lock already held by the process or thread, the requested object and range, and whether the request was blocking.
- Define one global order for locks that can be acquired together, including database, filesystem, and IPC locks.
- Avoid holding a low-level lock while calling code that may acquire higher-level locks or perform callbacks.
- Use timeouts and cancellation only as containment; fix the ownership graph that made circular waiting possible.
References
Looking for a different code? Search another status or error code.