Amend the manual, per POSIX [0], the function "shall unblock at least one of the threads".
This can happen in our implementation when the function is called w/o holding the corresponding mutex. If a thread is blocking on the futex lock, the sequence number will change and futex(2) will return EAGAIN. In that case 2 threads will be awoken. This was the reason why the test condvar3_1 from libpthread-regress [1] was sometimes failing. The test is now fixed, as POSIX mandates: "if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling [...] pthread_cond_signal()." While here remove an assert checking for NULL, dereferencing a NULL pointer should have the same effect. [0] http://pubs.opengroup.org/onlinepubs/9699919799/ [1] https://github.com/mpieuchot/libpthread-regress Index: lib/libc/thread/rthread_cond.c =================================================================== RCS file: /cvs/src/lib/libc/thread/rthread_cond.c,v retrieving revision 1.4 diff -u -p -r1.4 rthread_cond.c --- lib/libc/thread/rthread_cond.c 5 Sep 2017 02:40:54 -0000 1.4 +++ lib/libc/thread/rthread_cond.c 28 Jan 2019 16:38:01 -0000 @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <assert.h> #include <errno.h> #include <pthread.h> #include <stdint.h> @@ -52,7 +51,6 @@ pthread_cond_destroy(pthread_cond_t *con { pthread_cond_t cond; - assert(condp != NULL); cond = *condp; if (cond != NULL) { Index: lib/libpthread/man/pthread_cond_signal.3 =================================================================== RCS file: /cvs/src/lib/libpthread/man/pthread_cond_signal.3,v retrieving revision 1.8 diff -u -p -r1.8 pthread_cond_signal.3 --- lib/libpthread/man/pthread_cond_signal.3 5 Jun 2013 03:44:50 -0000 1.8 +++ lib/libpthread/man/pthread_cond_signal.3 28 Jan 2019 16:37:13 -0000 @@ -42,7 +42,7 @@ .Sh DESCRIPTION The .Fn pthread_cond_signal -function unblocks one thread waiting for the condition variable +function unblocks at least one thread waiting for the condition variable .Fa cond . .Sh RETURN VALUES If successful, the