sem_wait(3) is not always a cancellation point

From: Eric van Gyzen <eric_at_vangyzen.net>
Date: Wed, 12 Mar 2014 15:33:40 -0500
-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
Received on Wed Mar 12 2014 - 19:33:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:47 UTC