Title
mutex lock() missing error conditions
Status
nad
Section
[thread.mutex.requirements]
Submitter
Ion GaztaƱaga

Created on 2009-02-07.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Add to [thread.mutex.requirements], p12:

-12- Error conditions:

  • operation_not_permitted -- if the thread does not have the necessary permission to change the state of the mutex.
  • resource_deadlock_would_occur -- if the current thread already owns the mutex and is able to detect it.
  • device_or_resource_busy -- if the mutex is already locked and blocking is not possible.
  • state_not_recoverable -- if the state protected by the mutex is not recoverable.
Date: 2010-10-21.18:28:33

[ Summit: ]

Not a defect. Handling these error conditions is an implementation detail and must be handled below the C++ interface.

Date: 2009-02-07.00:00:00

POSIX 2008 adds two return values for pthread_mutex_xxxlock(): EOWNERDEAD (owner_dead) and ENOTRECOVERABLE (state_not_recoverable). In the first case the mutex is locked, in the second case the mutex is not locked.

Throwing an exception in the first case can be incompatible with the use of Locks, since the Lock::owns_lock() will be false when the lock is being destroyed.

Consider:

//Suppose mutex.lock() throws "owner_dead"
unique_lock ul(&mutex);
//mutex left locked if "owner_dead" is thrown

Throwing an exception with owner_dead might be also undesirable if robust-mutex support is added to C++ and the user has the equivalent of pthread_mutex_consistent() to notify the user has fixed the corrupted data and the mutex state should be marked consistent.

  1. For state_not_recoverable add it to the list of Error conditions:
  2. For owner_dead, no proposed resolution.
History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg4669
2010-10-21 18:28:33adminsetmessages: + msg4668
2009-02-07 00:00:00admincreate