From e4235d70672d9751d7718ddc2b52d0b426430768 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 16 Feb 2019 09:13:45 -0500 Subject: 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/thread/pthread_create.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/thread/pthread_create.c') diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 03cdea0a..cec82157 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -201,8 +201,6 @@ weak_alias(dummy, __pthread_tsd_size); static void *dummy_tsd[1] = { 0 }; weak_alias(dummy_tsd, __pthread_tsd_main); -volatile int __block_new_threads = 0; - static FILE *volatile dummy_file = 0; weak_alias(dummy_file, __stdin_used); weak_alias(dummy_file, __stdout_used); @@ -247,8 +245,6 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att attr._a_guardsize = __default_guardsize; } - if (__block_new_threads) __wait(&__block_new_threads, 0, 1, 1); - if (attr._a_stackaddr) { size_t need = libc.tls_size + __pthread_tsd_size; size = attr._a_stacksize; -- cgit v1.2.1