This is the mail archive of the
mailing list for the pthreas-win32 project.
Bug in pthread_cond_wait...
- To: pthreads mailing list <firstname.lastname@example.org>
- Subject: Bug in pthread_cond_wait...
- From: Lorin Hochstein <email@example.com>
- Date: Wed, 30 Jun 1999 14:43:16 -0400
As mentioned in my previous post, I believe there is a bug in the
pthread_cond_wait code. If the thread is cancelled while blocked in a
pthread_cond_wait, it does not properly restore the condition variable's
state, which can cause a subsequent call to pthread_cond_broadcast to
hang (broadcast will wait forever for the terminated thread to respond).
This is a big problem if you have one producer and multiple consumers,
and one of the consumers gets cancelled.
I don't know what the correct protocol is for submitting bugfixes.
However, for the impatient ones that are encountering the same problem
that I am attaching a patch with this e-mail.
> static int
> _restore_cond(void *cond)
> pthread_cond_t cv;
> cv = *(pthread_cond_t*)cond;
> return 0;
> * We must also ensure that the condition variable is
> * restored to the correct state.
> pthread_cleanup_push (_restore_cond, cond);
> pthread_cleanup_pop (0);