From owner-freebsd-current@FreeBSD.ORG Thu Mar 13 06:03:24 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 174218C3 for ; Thu, 13 Mar 2014 06:03:24 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0348194B; Thu, 13 Mar 2014 06:03:24 +0000 (UTC) Received: from xyf.my.dom (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2D63MHD068050; Thu, 13 Mar 2014 06:03:23 GMT (envelope-from davidxu@freebsd.org) Message-ID: <53214A54.4000901@freebsd.org> Date: Thu, 13 Mar 2014 14:04:04 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Eric van Gyzen , FreeBSD current Subject: Re: sem_wait(3) is not always a cancellation point References: <5320C4A4.7020109@vangyzen.net> In-Reply-To: <5320C4A4.7020109@vangyzen.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Mar 2014 06:03:24 -0000 On 2014/03/13 04:33, Eric van Gyzen wrote: > -current: > >>From my understand of POSIX, sem_wait(3) should always be a cancellation > point. However, when the semaphore's count is positive and the caller > successfully decrements the count, sem_wait(3) does not call > _pthread_testcancel(), so it's not a cancellation point. > > See this totally contrived test case: > > http://www.vangyzen.net/FreeBSD/patches/sem_wait_cancel.c > > This patch seems like an appropriate fix: > > http://www.vangyzen.net/FreeBSD/patches/sem_wait_cancel.diff > > It adds a call to _pthread_testcancel() in the same location as > _libc_sem_timedwait_compat() in libc/gen/sem.c. > > Is this a real bug, or am I missing something? > > Eric You are right, the _pthread_testcancel() call should be added. Thanks, David Xu