From owner-freebsd-current Wed Oct 14 19:15:46 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA13056 for freebsd-current-outgoing; Wed, 14 Oct 1998 19:15:46 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from highwind.com (hurricane.highwind.com [209.61.45.50]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA13050 for ; Wed, 14 Oct 1998 19:15:44 -0700 (PDT) (envelope-from info@highwind.com) Received: (from info@localhost) by highwind.com (8.8.6/8.8.6) id WAA22134; Wed, 14 Oct 1998 22:15:13 -0400 (EDT) Date: Wed, 14 Oct 1998 22:15:13 -0400 (EDT) Message-Id: <199810150215.WAA22134@highwind.com> From: HighWind Software Information To: taob@risc.org CC: lists@tar.com, current@FreeBSD.ORG In-reply-to: (message from Brian Tao on Wed, 14 Oct 1998 21:33:15 -0400 (EDT)) Subject: Re: Recent 3.0's are Depressing Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include #include 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