From owner-freebsd-bugs Fri Nov 27 21:29:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA05443 for freebsd-bugs-outgoing; Fri, 27 Nov 1998 21:29:22 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA05435 for ; Fri, 27 Nov 1998 21:29:21 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from Unknown UID 563@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id VAA11619; Fri, 27 Nov 1998 21:30:00 -0800 (PST) Received: from sturm.canonware.com (canonware.com [204.107.140.54]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA05103 for ; Fri, 27 Nov 1998 21:24:05 -0800 (PST) (envelope-from jasone@canonware.com) Received: from localhost (jasone@localhost) by sturm.canonware.com (8.8.8/8.8.8) with ESMTP id VAA00781 for ; Fri, 27 Nov 1998 21:21:00 -0800 (PST) (envelope-from jasone@canonware.com) Message-Id: Date: Fri, 27 Nov 1998 21:20:59 -0800 (PST) From: Jason Evans To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/8872: pthread_cond_timedwait() can cause lost pthread_cond_signal() Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8872 >Category: bin >Synopsis: pthread_cond_timedwait() can cause lost pthread_cond_signal() >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Nov 27 21:30:00 PST 1998 >Last-Modified: >Originator: Jason Evans >Organization: >Release: FreeBSD 2.2.7-STABLE i386 >Environment: FreeBSD orkan 2.2.7-STABLE FreeBSD 2.2.7-STABLE #0: Thu Nov 26 09:13:44 PST 1998 toor@orkan:/usr/src/sys/compile/CRASH_orkan i386 >Description: pthread_cond_timedwait() causes a thread to be unscheduled for a specified period of time, unless a condition becomes true. If that timeout expires, the thread is rescheduled, but it is left on the condition wait queue. This can cause a pthread_cond_signal() to be lost. >How-To-Repeat: 1) Call pthread_cond_timedwait() in thread A. 2) Let the timer expire. 3) Call pthread_cond_wait() in thread B. 4) Call pthread_cond_signal() in thread A. *** The signal will have no effect. 5) Call pthread_cond_signal() again in thread A. *** Thread B will be signaled. >Fix: It looks safe to ignore the return value of _thread_queue_remove(), but I may be mistaken. --- Begin patch ------------------------------------------------------------- *** /usr/src/lib/libc_r/uthread/uthread_kern.c.orig Fri Nov 27 16:10:16 1998 --- /usr/src/lib/libc_r/uthread/uthread_kern.c Fri Nov 27 16:05:16 1998 *************** *** 171,176 **** --- 171,185 ---- FD_ZERO(&pthread->data.select_da ta->writefds); FD_ZERO(&pthread->data.select_da ta->exceptfds); pthread->data.select_data->nfds = 0; + } else if (pthread->state == PS_COND_WAI T) { + /* + * The pthread_cond_timedwait() + * has timed out, so remove the + * thread from the condition's + * queue. + */ + _thread_queue_remove(pthread->qu eue, + pthread); } /* --- End patch --------------------------------------------------------------- >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message