]> granicus.if.org Git - musl/commit
rewrite __synccall in terms of global thread list
authorRich Felker <dalias@aerifal.cx>
Sat, 16 Feb 2019 14:13:45 +0000 (09:13 -0500)
committerRich Felker <dalias@aerifal.cx>
Sat, 16 Feb 2019 15:11:22 +0000 (10:11 -0500)
commite4235d70672d9751d7718ddc2b52d0b426430768
treecf4d965f2a440b641adca6fd3ddf5f17278e3210
parent8f11e6127fe93093f81a52b15bb1537edc3fc8af
rewrite __synccall in terms of global thread list

the __synccall mechanism provides stop-the-world synchronous execution
of a callback in all threads of the process. it is used to implement
multi-threaded setuid/setgid operations, since Linux lacks them at the
kernel level, and for some other less-critical purposes.

this change eliminates dependency on /proc/self/task to determine the
set of live threads, which in addition to being an unwanted dependency
and a potential point of resource-exhaustion failure, turned out to be
inaccurate. test cases provided by Alexey Izbyshev showed that it
could fail to reflect newly created threads. due to how the
presignaling phase worked, this usually yielded a deadlock if hit, but
in the worst case it could also result in threads being silently
missed (allowed to continue running without executing the callback).
src/internal/pthread_impl.h
src/thread/pthread_create.c
src/thread/synccall.c