RE: is there a chance for a race condition in pthread_mutex_[un]lock.c?

"Perez-Gonzalez, Inaky" <[email protected]> Wed, 17 Dec 2003 07:51:43 -0800
Newsgroups gmane.comp.lib.phil
Message-ID <[email protected]>
> From: Ulrich Drepper [mailto:[email protected]]
> Perez-Gonzalez, Inaky wrote:
> 
> > While squeezing my brains on some inconsistencies on the RT-NPTL
> > patches, I came across this issue, and I was wondering how to
> > fix it. Please tell me I am wrong:
> 
> If that happens, the user code is wrong.  There are many situations like
> this which can result in inconsistencies.  No mutex can be unlocked
> before the locking call returned.  If half-way through the
> pthread_mutex_lock call some other thread calls pthread_mutex_unlock
> this is a plain error.

Sounds reasonable. 

Still makes me nervous that this situation can go undetected. 
Would it be worth to assert that __owner != 0 on unlock() to 
catch this case?

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)