ENOTRECOVERABLE
Linux / POSIXERRORNotableIPCHIGH confidence

State Not Recoverable

Production Risk

Requires mutex destruction and reinitialization; always handle EOWNERDEAD correctly to prevent this.

What this means

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.

Why it happens
  1. 1pthread_mutex_consistent() was not called after receiving EOWNERDEAD
  2. 2The thread that called pthread_mutex_consistent() also died before unlocking
How to reproduce

pthread_mutex_lock() on a robust mutex that was not made consistent.

trigger — this will error
trigger — this will error
// 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

Destroy and reinitialize the mutex
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.

What not to do

Continue using the mutex after ENOTRECOVERABLE

The mutex is permanently broken; all lock attempts will return ENOTRECOVERABLE until it is destroyed and reinitialized.

Sources
Official documentation ↗

Linux Programmer Manual pthread_mutexattr_setrobust(3)

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Linux / POSIX errors