]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Ensure thread library is initialized in pthread_testcancel().
authorjhb <jhb@FreeBSD.org>
Wed, 21 Mar 2018 21:13:26 +0000 (21:13 +0000)
committerjhb <jhb@FreeBSD.org>
Wed, 21 Mar 2018 21:13:26 +0000 (21:13 +0000)
commit995b92da50320ea34b8d83ad2519a650cdd124d9
tree0d3638256d76ee6eef23a7322cd1f1fd33f15bce
parente5ec0a0e43511ac5e2aec861df826af4cbd7f844
Ensure thread library is initialized in pthread_testcancel().

Call _thr_check_init() before reading curthread in pthread_testcancel().

If a constructor in a library creates a semaphore via sem_init() and
then waits for it via sem_wait(), the program can core dump in
_pthread_testcancel() called from sem_wait().  This is because the
semaphore implementation lives in libc, so the library's constructors
can be run before libthr's constructors.

Reported by: arichardson
Reviewed by: kib
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14786
lib/libthr/thread/thr_cancel.c