State Not Recoverable
Production Risk
Requires mutex destruction and reinitialization; always handle EOWNERDEAD correctly to prevent this.
ENOTRECOVERABLE (errno 131) is returned by pthread_mutex_lock() for robust mutexes when the mutex is permanently unrecoverable — either because pthread_mutex_consistent() was not called after EOWNERDEAD, or because it was called and then the thread died again.
- 1pthread_mutex_consistent() was not called after receiving EOWNERDEAD
- 2The thread that called pthread_mutex_consistent() also died before unlocking
pthread_mutex_lock() on a robust mutex that was not made consistent.
// If previous EOWNERDEAD holder didn't call pthread_mutex_consistent(): int rc = pthread_mutex_lock(&mtx); // rc == ENOTRECOVERABLE — mutex is permanently broken
expected output
pthread_mutex_lock returned ENOTRECOVERABLE
Fix
Destroy and reinitialize the mutex
WHEN When ENOTRECOVERABLE is returned
if (rc == ENOTRECOVERABLE) {
// Mutex is permanently unusable — destroy and recreate
pthread_mutex_destroy(&mtx);
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST);
pthread_mutex_init(&mtx, &attr);
pthread_mutexattr_destroy(&attr);
// Also reinitialize and validate the protected data
reinitialize_shared_data(&shared);
}Why this works
ENOTRECOVERABLE is permanent for that mutex instance; the only fix is destroy + reinit.
✕ Continue using the mutex after ENOTRECOVERABLE
The mutex is permanently broken; all lock attempts will return ENOTRECOVERABLE until it is destroyed and reinitialized.
Linux Programmer Manual pthread_mutexattr_setrobust(3)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev