[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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

> From: Ulrich Drepper [mailto:drepper redhat com]
> 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)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]