svn commit: r332633 - in stable: 10/lib/libthr/thread 11/lib/libthr/thread
John Baldwin
jhb at FreeBSD.org
Mon Apr 16 20:45:22 UTC 2018
Author: jhb
Date: Mon Apr 16 20:45:21 2018
New Revision: 332633
URL: https://svnweb.freebsd.org/changeset/base/332633
Log:
MFC 331324: 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.
Sponsored by: DARPA / AFRL
Modified:
stable/10/lib/libthr/thread/thr_cancel.c
Directory Properties:
stable/10/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/11/lib/libthr/thread/thr_cancel.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/10/lib/libthr/thread/thr_cancel.c
==============================================================================
--- stable/10/lib/libthr/thread/thr_cancel.c Mon Apr 16 19:33:04 2018 (r332632)
+++ stable/10/lib/libthr/thread/thr_cancel.c Mon Apr 16 20:45:21 2018 (r332633)
@@ -130,8 +130,10 @@ _pthread_setcanceltype(int type, int *oldtype)
void
_pthread_testcancel(void)
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
+ _thr_check_init();
+ curthread = _get_curthread();
testcancel(curthread);
}
More information about the svn-src-stable
mailing list