Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Mar 2014 14:04:04 +0800
From:      David Xu <davidxu@freebsd.org>
To:        Eric van Gyzen <eric@vangyzen.net>, FreeBSD current <freebsd-current@freebsd.org>
Subject:   Re: sem_wait(3) is not always a cancellation point
Message-ID:  <53214A54.4000901@freebsd.org>
In-Reply-To: <5320C4A4.7020109@vangyzen.net>
References:  <5320C4A4.7020109@vangyzen.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53214A54.4000901>