View Issue Details

IDProjectCategoryView StatusLast Update
00011151003.1(2016/18)/Issue7+TC2System Interfacespublic2024-06-11 09:09
ReporterFlorian Weimer Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status ClosedResolutionAccepted As Marked 
NameFlorian Weimer
OrganizationRed Hat
User Reference
Sectionpthread_mutex_lock
Page Number1672
Line Number1672
Interp Status---
Final Accepted TextSee 0001115:0004056
Summary0001115: Lock acquisition state after pthread_mutex_lock with EOWNERDEAD
DescriptionThe text currently says:


If mutex is a robust mutex and the owning thread terminated while holding the mutex lock, a call to pthread_mutex_lock() may return the error value [EOWNERDEAD] even if the process in which the owning thread resides has not terminated. In these cases, the mutex is locked by the thread but the state it protects is marked as inconsistent.


It is unclear to which thread “the thread” in the last sentence refers.

The current text goes on with:


The application should ensure that the state is made consistent for reuse and when that is complete call pthread_mutex_consistent(). If the application is unable to recover the state, it should unlock the mutex without a prior call to pthread_mutex_consistent(), after which the mutex is marked permanently unusable.


Due to the ambiguity above, it is unclear whether the current thread (which calls pthread_mutex_consistent()) has acquired the lock after the call, and whether it is correct to call pthread_mutex_unlock() afterwards.
Desired ActionI suggest to replace “the thread” with “the thread which has called pthread_mutex_lock() resulting in an [EOWNERDEAD] error”.

As a result, the mutex is in the acquired state, and it remains so after a call pthread_mutex_consistent(). Then it's allowed to call pthread_mutex_unlock() whether or not pthread_mutex_consistent() has been called.

Another implication is that because the new thread acquires the lock, only one thread can return [EOWNERDEAD], and the others will block. I do not know if this matches actual implementation practice, but it is the only way robust mutexes can recovery without external synchronization.
Tagstc3-2008

Activities

geoffclare

2017-01-13 15:03

manager   bugnote:0003542

I have no objection to improving the text here, but the localised ambiguity disappears when reading the DESCRIPTION section as a whole, because the first sentence clearly states "The mutex object referenced by mutex shall be locked by a call to pthread_mutex_lock() that returns zero or [EOWNERDEAD]."

nick

2018-07-19 15:58

manager   bugnote:0004056

Last edited: 2018-07-19 16:01

On page 1672 line 54500 change:
    If mutex is a robust mutex and the owning thread terminated while holding the mutex lock, a call to pthread_mutex_lock() may return the error value [EOWNERDEAD] even if the process in which the owning
    thread resides has not terminated.
    In these cases, the mutex is locked by the thread but the state it protects is marked as inconsistent.
    
to:
    If mutex is a robust mutex and the owning thread terminated while holding the mutex lock, a call to pthread_mutex_lock() may return the error value [EOWNERDEAD] even if the process in which the owning
    thread resides has not terminated.
    In these cases, the mutex shall be locked by the calling thread but the state it protects is marked as inconsistent.

Issue History

Date Modified Username Field Change
2017-01-13 14:41 Florian Weimer New Issue
2017-01-13 14:41 Florian Weimer Name => Florian Weimer
2017-01-13 14:41 Florian Weimer Organization => Red Hat
2017-01-13 14:41 Florian Weimer Section => pthread_mutex_lock
2017-01-13 14:41 Florian Weimer Page Number => unknown
2017-01-13 14:41 Florian Weimer Line Number => unknown
2017-01-13 15:03 geoffclare Note Added: 0003542
2018-07-19 15:58 nick Page Number unknown => 1672
2018-07-19 15:58 nick Line Number unknown => 1672
2018-07-19 15:58 nick Interp Status => ---
2018-07-19 15:58 nick Note Added: 0004056
2018-07-19 15:58 nick Status New => Resolved
2018-07-19 15:58 nick Resolution Open => Accepted As Marked
2018-07-19 15:59 nick Final Accepted Text => See Bugnote:0004056
2018-07-19 15:59 nick Final Accepted Text See Bugnote:0004056 => See 0000225:0000405
2018-07-19 16:00 nick Tag Attached: tc3-2008
2018-07-19 16:00 nick Note Edited: 0004056
2018-07-19 16:01 nick Note Edited: 0004056
2018-07-19 16:02 nick Final Accepted Text See 0000225:0000405 => See 0001115:0004056
2019-10-30 11:26 geoffclare Status Resolved => Applied
2024-06-11 09:09 agadmin Status Applied => Closed