This is the mail archive of the
pthreads-win32@sourceware.cygnus.com
mailing list for the pthreas-win32 project.
Re: condvar.c
- To: "Bossom, John" <John.Bossom@Cognos.COM>
- Subject: Re: condvar.c
- From: "Mark E. Armstrong" <avail@pacbell.net>
- Date: Thu, 27 May 1999 09:01:55 -0700
- CC: "'Peter Slacik'" <Peter.Slacik@tatramed.sk>, Pthreads-Win32 Mailing List <pthreads-win32@sourceware.cygnus.com>
- Organization: Avail Solutions LLC
- References: <27CB1FE98AE7D211B9D000805F31D80005BBCD@sotr0087.cognos.com>
Greetings,
After reading the referenced messages and checking the code WRT to
the incorrect equality check, I noticed the assignment made to
cv->wasBroadcast should be moved to prevent a possible memory
fault when cv is dereferenced for auto-init objects:
************ original condvar.c starting at line 828 ************
cv = *cond;
cv->wasBroadcast = TRUE;
/*
* No-op if the CV is static and hasn't been initialised yet.
*/
if (cv == (pthread_cond_t) _PTHREAD_OBJECT_AUTO_INIT)
{
return 0;
}
************* corrected condvar.c starting at line 828 ************
cv = *cond;
/*
* No-op if the CV is static and hasn't been initialised yet.
*/
if (cv == (pthread_cond_t) _PTHREAD_OBJECT_AUTO_INIT)
{
return 0;
}
cv->wasBroadcast = TRUE;
**********************************************************
Took a quick look through the rest of the 99-04-07 snapshot for similar
errors and didn't find any more.
Enjoy,
Mark Armstrong
"Bossom, John" wrote:
> You are correct... (assuming the code snippet you sent originated from my
> original source... it looks like it does... I don't have the win32-pthreads
> snapshot).
>
> -----Original Message-----
> From: Peter Slacik [mailto:Peter.Slacik@tatramed.sk]
> Sent: Wednesday, May 26, 1999 12:19 PM
> To: Pthreads-Win32 Mailing List
> Subject: condvar.c
>
> Hi thread writers,
>
> I tried to upgrade (after half year) to the current pthreads snapshot,
> snap-1999-04-07, and I suspect one inequality test to be wrong:
>
> cvs diff -c -r1.1 -r1.2 condvar.c
> Index: condvar.c
> ===================================================================
> RCS file: pthread/condvar.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -c -r1.1 -r1.2
> *** condvar.c 1999/04/07 12:18:40 1.1
> --- condvar.c 1999/05/26 16:10:08 1.2
> ***************
> *** 851,857 ****
> * Wait for all the awakened threads to acquire their part of
> * the counting semaphore
> */
> ! if (WaitForSingleObject (cv->waitersDone, INFINITE) !=
> WAIT_OBJECT_0)
> {
> result = 0;
> --- 851,857 ----
> * Wait for all the awakened threads to acquire their part of
> * the counting semaphore
> */
> ! if (WaitForSingleObject (cv->waitersDone, INFINITE) ==
> WAIT_OBJECT_0)
> {
> result = 0;
>
> Please check this.
>
> Regards
> Peter Slacik