musl/src
Rich Felker 23f21c304f always block signals in pthread_exit before decrementing thread count
the thread count (1+libc.threads_minus_1) must always be greater than
or equal to the number of threads which could have application code
running, even in an async-signal-safe sense. there is at least one
dangerous race condition if this invariant fails to hold: dlopen could
allocate too little TLS for existing threads, and a signal handler
running in the exiting thread could claim the allocated TLS for itself
(via __tls_get_addr), leaving too little for the other threads it was
allocated for and thereby causing out-of-bounds access.

there may be other situations where it's dangerous for the thread
count to be too low, particularly in the case where only one thread
should be left, in which case locking may be omitted. however, all
such code paths seem to arise from undefined behavior, since
async-signal-unsafe functions are not permitted to be called from a
signal handler that interrupts pthread_exit (which is itself
async-signal-unsafe).

this change may also simplify logic in __synccall and improve the
chances of making __synccall async-signal-safe.
2013-04-26 15:47:44 -04:00
..
aio fix lio_listio return value in LIO_WAIT mode 2013-01-13 23:15:39 +01:00
complex complex: add C11 CMPLX macros and replace cpack with them 2012-11-13 01:31:49 +01:00
conf report support of TPS option in unistd.h and sysconf 2012-11-11 15:54:20 -05:00
crypt comment potentially-confusing use of struct crypt_data type 2013-04-20 14:07:01 -04:00
ctype fix types for wctype_t and wctrans_t 2013-03-04 19:22:14 -05:00
dirent use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
env add support for program_invocation[_short]_name 2013-04-06 17:50:37 -04:00
errno fix typo in newly-added error message for EOWNERDEAD 2013-02-07 03:13:35 -05:00
exit __assert_fail(): remove _Noreturn, to get proper stacktraces 2013-01-04 20:36:34 +01:00
fcntl provide emulation of fcntl F_DUPFD_CLOEXEC on old kernels 2013-03-26 22:54:57 -04:00
fenv fenv support for ppc, untested 2012-11-18 16:31:14 -05:00
internal add support for program_invocation[_short]_name 2013-04-06 17:50:37 -04:00
ipc fix shmdt syscall calling convention on old archs 2012-10-28 15:04:26 -04:00
ldso make dynamic linker accept : or \n as path separator 2013-04-20 11:51:58 -04:00
legacy more close-on-exec fixes, mostly using new "e" flag to fopen 2012-09-29 18:14:46 -04:00
linux fix signalfd not to ignore flags 2013-04-07 23:19:00 -04:00
locale use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
malloc page-align initial brk value used by malloc in shared libc 2012-12-07 22:33:11 -05:00
math math: erf and erfc cleanup 2013-01-07 23:54:13 +01:00
misc Add ABI compatability aliases. 2013-04-05 23:20:28 -07:00
mman clean up and fix logic for making mmap fail on invalid/unsupported offsets 2012-12-20 12:16:02 -05:00
mq use restrict everywhere it's required by c99 and/or posix 2008 2012-09-06 22:44:55 -04:00
multibyte mbrtowc: do not leave mbstate_t in permanent-fail state after EILSEQ 2013-04-08 23:09:11 -04:00
network getifaddrs: implement proper ipv6 netmasks 2013-04-09 16:52:13 +02:00
passwd add put*ent functions for passwd/group files and similar for shadow 2013-04-04 19:23:47 -04:00
prng ditch the priority inheritance locks; use malloc's version of lock 2012-04-24 16:32:23 -04:00
process remove explicit locking to prevent __synccall setuid during posix_spawn 2013-04-26 15:09:49 -04:00
regex revert regex "cleanup" that seems unjustified and may break backtracking 2013-02-01 01:10:59 -05:00
sched add support for thread scheduling (POSIX TPS option) 2012-11-11 15:38:04 -05:00
search search: add comments to tsearch_avl.c 2012-05-13 01:50:53 +02:00
select remove __SYSCALL_SSLEN arch macro in favor of using public _NSIG 2013-03-26 23:07:31 -04:00
setjmp remove fenv saving/loading code from setjmp/longjmp on arm 2012-12-05 19:13:47 -05:00
signal fix reversed argument order x86_64 sigsetjmp's call to sigprocmask 2013-04-22 10:17:56 -04:00
stat add obsolete futimesat() 2012-12-06 20:27:54 +01:00
stdio fix argument omission in ABI-compat weak_alias for fscanf 2013-04-06 17:15:58 -04:00
stdlib clean up stdio_impl.h 2012-11-08 16:39:41 -05:00
string Add ABI compatability aliases. 2013-04-05 23:20:28 -07:00
temp use memcmp instead of str[n]cmp for temp function XXXXXX checking 2013-02-20 23:01:22 -05:00
termios
thread always block signals in pthread_exit before decrementing thread count 2013-04-26 15:47:44 -04:00
time silence nonsensical warnings in timer_create 2013-04-06 18:32:11 -04:00
unistd in pipe2, use pipe() rather than __syscall(SYS_pipe, ...) for fallback 2013-03-25 11:34:22 -04:00