Date: Wed, 14 Oct 1998 22:15:13 -0400 (EDT) From: HighWind Software Information <info@highwind.com> To: taob@risc.org Cc: lists@tar.com, current@FreeBSD.ORG Subject: Re: Recent 3.0's are Depressing Message-ID: <199810150215.WAA22134@highwind.com> In-Reply-To: <Pine.GSO.3.96.981014212317.5865K-100000@tor-dev1.nbc.netcom.ca> (message from Brian Tao on Wed, 14 Oct 1998 21:33:15 -0400 (EDT))
next in thread | previous in thread | raw e-mail | index | archive | help
Well... I think we have a test program that illustrates a (perhaps
"the") bug in the new libc_r.a's. It appears that
pthread_cond_timedwait() is now broken.
We updated our machine to the latest libc_r. Check out the following
program.
Haven't looked at the libc_r code yet.
-Rob
---
/*
Illustration of FreeBSD pthread_cond_wait() bug
This program sets up a timed conditional wait. It just calls
pthread_cond_timedwait(). This should BLOCK for 15 seconds and the program
should terminate normally.
However, because of some bugs in FreeBSD, the pthread_cond_timedwait()
returns with no error. It looks as if someone has signaled the
condition. Clearly, that is impossible and there is some kind of bug!
This early return is causing Typhoon to SPIN endlessly.
g++ -o condBug -D_REENTRANT -D_THREAD_SAFE -g -Wall condBug.C -pthread
*/
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
int main(int, char **)
{
pthread_mutex_t lock;
pthread_cond_t condition;
// Initialize Lock
pthread_mutexattr_t lock_attr;
assert(!::pthread_mutexattr_init(&lock_attr));
assert(!::pthread_mutex_init(&lock, &lock_attr));
assert(!::pthread_mutexattr_destroy(&lock_attr));
// Initialize Condition
pthread_condattr_t cond_attr;
assert(!::pthread_condattr_init(&cond_attr));
assert(!::pthread_cond_init(&condition, &cond_attr));
assert(!::pthread_condattr_destroy(&cond_attr));
// Grab current time
time_t currentTime = ::time(0);
// Lock the lock
assert(!::pthread_mutex_lock(&lock));
// Wait in the condition for 15 seconds
timespec timeOut;
timeOut.tv_sec = currentTime + 15;
timeOut.tv_nsec = 0;
int err = ::pthread_cond_timedwait(&condition, &lock, &timeOut);
// We better get an error (we should have TIMED OUT!)
assert(err);
// 15 seconds SHOULD have passed, so 5 seconds DEFINATELY should have!!
assert(::time(0) >= currentTime + 5);
return EXIT_SUCCESS;
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810150215.WAA22134>
