Owner Died
Production Risk
Requires careful data recovery logic; always call pthread_mutex_consistent() and verify data integrity.
EOWNERDEAD (errno 130) is returned by pthread_mutex_lock() for robust mutexes when the thread or process that last held the mutex died while still holding it, leaving the protected data in an undefined state.
- 1A thread holding a robust mutex was killed by a signal
- 2A process holding a process-shared robust mutex crashed
pthread_mutex_lock() on a robust mutex whose owner crashed.
pthread_mutex_t mtx; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST); pthread_mutex_init(&mtx, &attr); // If previous owner died holding this mutex: int rc = pthread_mutex_lock(&mtx); // rc == EOWNERDEAD — lock acquired but data may be inconsistent
expected output
pthread_mutex_lock returned EOWNERDEAD
Fix
Make the mutex consistent after EOWNERDEAD
WHEN After acquiring a robust mutex that returned EOWNERDEAD
int rc = pthread_mutex_lock(&mtx);
if (rc == EOWNERDEAD) {
// Inspect and repair the protected data structure
repair_shared_data(&shared);
// Mark the mutex consistent so other threads can use it
pthread_mutex_consistent(&mtx);
// Now use it normally
} else if (rc != 0) {
// Other error
}Why this works
pthread_mutex_consistent() must be called after EOWNERDEAD to re-enable the mutex; without it, all subsequent lock attempts return ENOTRECOVERABLE.
✕ Ignore EOWNERDEAD and use the shared data
The data protected by the mutex may be in a corrupt or inconsistent state after the owner died.
Linux Programmer Manual pthread_mutexattr_setrobust(3)
pthread_mutex_consistent(3) ↗Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev