about summary refs log tree commit diff
path: root/nptl
Commit message (Collapse)AuthorAgeFilesLines
* string: Remove old TLS usage on strsignalAdhemerval Zanella2020-07-072-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The per-thread state is refactored two use two strategies: 1. The default one uses a TLS structure, which will be placed in the static TLS space (using __thread keyword). 2. Linux allocates via struct pthread and access it through THREAD_* macros. The default strategy has the disadvantage of increasing libc.so static TLS consumption and thus decreasing the possible surplus used in some scenarios (which might be mitigated by BZ#25051 fix). It is used only on Hurd, where accessing the thread storage in the in single thread case is not straightforward (afaiu, Hurd developers could correct me here). The fallback static allocation used for allocation failure is also removed: defining its size is problematic without synchronizing with translated messages (to avoid partial translation) and the resulting usage is not thread-safe. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* linux: Fix __NSIG_WORDS and add __NSIG_BYTESAdhemerval Zanella2020-07-072-2/+2
| | | | | | | | | | | | | | The __NSIG_WORDS value is based on minimum number of words to hold the maximum number of signals supported by the architecture. This patch also adds __NSIG_BYTES, which is the number of bytes required to represent the supported number of signals. It is used in syscalls which takes a sigset_t. Checked on x86_64-linux-gnu and i686-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add the __libc_single_threaded variableFlorian Weimer2020-07-061-0/+5
| | | | | | | | | | | | | | The variable is placed in libc.so, and it can be true only in an outer libc, not libcs loaded via dlmopen or static dlopen. Since thread creation from inner namespaces does not work, pthread_create can update __libc_single_threaded directly. Using __libc_early_init and its initial flag, implementation of this variable is very straightforward. A future version may reset the flag during fork (but not in an inner namespace), or after joining all threads except one. Reviewed-by: DJ Delorie <dj@redhat.com>
* Linux: Perform rseq registration at C startup and thread creationMathieu Desnoyers2020-07-061-0/+13
| | | | | | | | | | | | | | | | | | | Register rseq TLS for each thread (including main), and unregister for each thread (excluding main). "rseq" stands for Restartable Sequences. See the rseq(2) man page proposed here: https://lkml.org/lkml/2018/9/19/647 Those are based on glibc master branch commit 3ee1e0ec5c. The rseq system call was merged into Linux 4.18. The TLS_STATIC_SURPLUS define is increased to leave additional room for dlopen'd initial-exec TLS, which keeps elf/tst-auditmany working. The increase (76 bytes) is larger than 32 bytes because it has not been increased in quite a while. The cost in terms of additional TLS storage is quite significant, but it will also obscure some initial-exec-related dlopen failures.
* tst-cancel4: deal with ENOSYS errorsSamuel Thibault2020-07-051-4/+38
| | | | | | | | | | The Hurd port doesn't have support for sigwaitinfo, sigtimedwait, and msgget yet, so let us ignore the test for these when they return ENOSYS. * nptl/tst-cancel4.c (tf_sigwaitinfo): Fallback on sigwait when sigwaitinfo returns ENOSYS. (tf_sigtimedwait): Likewise with sigtimedwait. (tf_msgrcv, tf_msgsnd): Fallback on tf_usleep when msgget returns ENOSYS.
* htl: Enable cancel*16 an cancel*20 testsSamuel Thibault2020-06-295-507/+2
| | | | | | | | | | * nptl/tst-cancel16.c, tst-cancel20.c, tst-cancelx16.c, tst-cancelx20.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here. * sysdeps/mach/hurd/i386/Makefile: Xfail tst-cancel*16 for now: missing barrier pshared support, but test should be working otherwise.
* tst-cancel4-common.c: fix calling socketpairSamuel Thibault2020-06-261-1/+1
| | | | | | | | | | | PF_UNIX was actually never intended to be passed as protocol parameter to socket() calls: it is a protocol family, not a protocol. It happens that Linux introduced accepting it during its 2.0 development, but it shouldn't. OpenBSD kernels accept it as well, but FreeBSD and NetBSD rightfully do not. GNU/Hurd does not either. * nptl/tst-cancel4-common.c (do_test): Pass 0 instead of PF_UNIX as protocol.
* nptl: Don't madvise user provided stackSzabolcs Nagy2020-06-251-2/+3
| | | | | | | | | | | | | | | User provided stack should not be released nor madvised at thread exit because it's owned by the user. If the memory is shared or file based then MADV_DONTNEED can have unwanted effects. With memory tagging on aarch64 linux the tags are dropped and thus it may invalidate pointers. Tested on aarch64-linux-gnu with MTE, it fixes FAIL: nptl/tst-stack3 FAIL: nptl/tst-stack3-mem
* htl: Make sem_*wait cancellations pointsSamuel Thibault2020-06-243-131/+1
| | | | | | | | | | | | | | By aligning its implementation on pthread_cond_wait. * sysdeps/htl/sem-timedwait.c (cancel_ctx): New structure. (cancel_hook): New function. (__sem_timedwait_internal): Check for cancellation and register cancellation hook that wakes the thread up, and check again for cancellation on exit. * nptl/tst-cancel13.c, nptl/tst-cancelx13.c: Move to... * sysdeps/pthread/: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here.
* htl: Enable tst-cancel25 testSamuel Thibault2020-06-242-172/+1
| | | | | | | | * nptl/tst-cancel25.c: Move to... * sysdeps/pthread/tst-cancel25.c: ... here. (tf2) Do not test for SIGCANCEL when it is not defined. * nptl/Makefile: Move corresponding reference to... * sysdeps/pthread/Makefile: ... here.
* nptl: Remove now-spurious tst-cancelx9 referencesSamuel Thibault2020-06-171-2/+1
| | | | | | | | They were to be moved to sysdeps/pthread/Makefile in 45fce058f ('htl: Enable more cancellation tests') * nptl/Makefile: (tests): Remove tst-cancelx9. (CFLAGS-tst-cancelx9.c): Remove.
* htl: Enable more cancellation testsSamuel Thibault2020-06-145-241/+1
| | | | | | | | * nptl/tst-cancel-self-cancelstate.c, tst-cancel-self.c, tst-cancel9.c, tst-cancelx9.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here.
* htl: Enable more cancel testsSamuel Thibault2020-06-108-512/+7
| | | | | | | * nptl/tst-cancel11.c, tst-cancel21-static.c, tst-cancel21.c, tst-cancel6.c, tst-cancelx11.c, tst-cancelx21.c, tst-cancelx6.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here.
* pthread: Move back linking rules to nptl and htlSamuel Thibault2020-06-081-0/+18
| | | | | | | | | | | | | d6d74ec16 ('htl: Enable more tests') moved the linking rules from nptl/Makefile and htl/Makefile to the shared sysdeps/pthread/Makefile. But e.g. on powerpc some tests are added in sysdeps/powerpc/Makefile, which is included *after* sysdeps/pthread/Makefile, and thus the tests don't get affected by the rules and fail to link. For now let's just copy over the set of rules in both nptl/Makefile and htl/Makefile. * sysdeps/pthread/Makefile: Move libpthread linking rules to... * htl/Makefile: ... here and... * nptl/Makefile: ... there.
* htl: Enable more testsSamuel Thibault2020-06-0711-735/+4
| | | | | | | | | | * nptl/tst-_res1.c, tst-_res1mod1.c, tst-_res1mod2.c, tst-atfork2.c, tst-atfork2mod.c, tst-fini1.c, tst-fini1mod.c, tst-tls4.c, tst-tls4moda.c, tst-tls4modb.c: Move to... * sysdeps/pthread: ... here. Rename tst-tls4.c to tst-pt-tls4.c to avoid conflicting with elf/tst-tls4.c. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here.
* htl: Enable but XFAIL tst-flock2, tst-signal1, tst-signal2Samuel Thibault2020-06-074-646/+1
| | | | | | | | | | | They need setpshared support. * nptl/tst-flock2.c, tst-signal1.c, tst-signal2.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding tests references to... * sysdeps/pthread/Makefile: ... here. * sysdeps/mach/hurd/i386/Makefile (test-xfail-tst-flock2, test-xfail-tst-signal1, test-xfail-tst-signal2): Add.
* htl: Enable more testsSamuel Thibault2020-06-0798-7328/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * htl/Makefile: Remove rules adding libpthread.so and libpthread.a to link lines. * nptl/Makefile: Move rules adding libpthread.so and libpthread.a to link lines to... * sysdeps/pthread/Makefile: ... here. * nptl/eintr.c, tst-align.c tst-align3.c tst-atfork1.c tst-backtrace1.c tst-bad-schedattr.c tst-cancel-self-canceltype.c tst-cancel-self-cleanup.c tst-cancel-self-testcancel.c tst-cancel1.c tst-cancel10.c tst-cancel12.c tst-cancel14.c tst-cancel15.c tst-cancel18.c tst-cancel19.c tst-cancel2.c tst-cancel22.c tst-cancel23.c tst-cancel26.c tst-cancel27.c tst-cancel28.c tst-cancel3.c tst-cancel8.c tst-cancelx1.c tst-cancelx10.c tst-cancelx12.c tst-cancelx14.c tst-cancelx15.c tst-cancelx18.c tst-cancelx2.c tst-cancelx3.c tst-cancelx8.c tst-cleanup0.c tst-cleanup0.expect tst-cleanup1.c tst-cleanup2.c tst-cleanup3.c tst-cleanupx0.c tst-cleanupx0.expect tst-cleanupx1.c tst-cleanupx2.c tst-cleanupx3.c tst-clock1.c tst-create-detached.c tst-detach1.c tst-eintr2.c tst-eintr3.c tst-eintr4.c tst-eintr5.c tst-exec1.c tst-exec2.c tst-exec3.c tst-exit1.c tst-exit2.c tst-exit3.c tst-flock1.c tst-fork1.c tst-fork2.c tst-fork3.c tst-fork4.c tst-getpid3.c tst-kill1.c tst-kill2.c tst-kill3.c tst-kill4.c tst-kill5.c tst-kill6.c tst-locale1.c tst-locale2.c tst-memstream.c tst-popen1.c tst-raise1.c tst-sem5.c tst-setuid3.c tst-signal4.c tst-signal5.c tst-signal6.c tst-signal8.c tst-stack1.c tst-stdio1.c tst-stdio2.c tst-sysconf.c tst-tls1.c tst-tls2.c tst-tsd1.c tst-tsd2.c tst-tsd5.c tst-tsd6.c tst-umask1.c tst-unload.c tst-unwind-thread.c tst-vfork1.c tst-vfork1x.c tst-vfork2.c tst-vfork2x.c: Move tests to... * sysdeps/pthread: ... here. Rename tst-popen1.c -> tst-pt-popen1.c tst-align.c -> tst-pt-align.c tst-align3.c -> tst-pt-align3.c tst-sysconf.c -> tst-pt-sysconf.c tst-tls1.c -> tst-pt-tls1.c tst-tls2.c -> tst-pt-tls2.c tst-vfork1.c -> tst-pt-vfork1.c tst-vfork2.c -> tst-pt-vfork2.c to avoid conflicting with libio/tst-popen1.c, elf/tst-align.c, posix/tst-sysconf.c, elf/tst-tls1.c, elf/tst-tls2.c, posix/tst-vfork1.c, posix/tst-vfork2.c. * nptl/Makefile: Move corresponding tests references and special rules to... * sysdeps/pthread/Makefile: ... here. * sysdeps/pthread/tst-stack1.c (do_test): Do not clamp stack size to PTHREAD_STACK_MIN if not defined. Tested on linux-x86_64 and hurd-i386
* htl: Add sem_clockwait supportSamuel Thibault2020-06-072-64/+1
| | | | | | | | | | | | | * sysdeps/htl/sem-timedwait.c (__sem_timedwait_internal): Add clock_id parameter instead of hardcoding CLOCK_REALTIME. (__sem_clockwait): New function. (sem_clockwait): New weak alias. * sysdeps/htl/sem-wait.c (__sem_timedwait_internal): Update declaration. (__sem_wait): Update call to __sem_timedwait_internal. * htl/Versions (GLIBC_2.32): Add sem_clockwait. * sysdeps/mach/hurd/i386/libpthread.abilist (sem_clockwait): Add symbol. * nptl/Makefile (tests): Move tst-sem5 to... * sysdeps/pthread/Makefile (tests): ... here.
* nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_npFlorian Weimer2020-06-029-8/+360
| | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Make pthread_attr_t dynamically extensibleFlorian Weimer2020-06-028-27/+79
| | | | | | | This introduces the function __pthread_attr_extension to allocate the extension space, which is freed by pthread_attr_destroy. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Destroy the default thread attribute as part of freeresFlorian Weimer2020-06-023-0/+13
| | | | | | This avoids a spurious memory leak report by valgrind. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Change type of __default_pthread_attrFlorian Weimer2020-06-028-15/+14
| | | | | | | | | | | | union pthread_attr_transparent has always the correct size, even if pthread_attr_t has padding that is not present in struct pthread_attr. This should not result in an observable behavioral change. The existing code appears to have been correct, but it was brittle because it was not clear which functions were allowed to write to an entire pthread_attr_t argument (e.g., by copying it). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Use __pthread_attr_setaffinity_np in pthread_getattr_npFlorian Weimer2020-06-021-16/+14
| | | | | | | This avoids duplicating the code for the affinity mask allocation handling. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Use __pthread_getattr_default_np in pthread_createFlorian Weimer2020-06-021-25/+7
| | | | | | This removes another instance of custom attribute copying code. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Add internal alias __pthread_getattr_default_npFlorian Weimer2020-06-023-1/+6
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* htl: Make pthread_cond_destroy wait for threads to be wokenSamuel Thibault2020-06-013-176/+1
| | | | | | | | | | | | | | | | | | This allows to reuse the storage after calling pthread_cond_destroy. * sysdeps/htl/bits/types/struct___pthread_cond.h (__pthread_cond): Replace unused struct __pthread_condimpl *__impl field with unsigned int __wrefs. (__PTHREAD_COND_INITIALIZER): Update accordingly. * sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Register as waiter in __wrefs field. On unregistering, wake any pending pthread_cond_destroy. * sysdeps/htl/pt-cond-destroy.c (__pthread_cond_destroy): Register wake request in __wrefs. * nptl/Makefile (tests): Move tst-cond20 tst-cond21 to... * sysdeps/pthread/Makefile (tests): ... here. * nptl/tst-cond20.c nptl/tst-cond21.c: Move to... * sysdeps/pthread/tst-cond20.c sysdeps/pthread/tst-cond21.c: ... here.
* htl: Enable more cond testsSamuel Thibault2020-06-011-1/+1
| | | | | * nptl/Makefile (tests): Move tst-cond11 and tst-cond27 to... * sysdeps/pthread/Makefile (tests): ... here.
* htl: Add clock variantsSamuel Thibault2020-05-2621-1421/+441
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * htl/pt-join.c (__pthread_join): Move implementation to... (__pthread_join_common): ... new function. Add try, timed and clock support. (__pthread_join): Reimplement on top of __pthread_join_common. (__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np): Implement on top of __pthread_join_common. (pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New aliases. * hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait, __lll_abstimed_lock): Check for supported clock. * sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Add clockid parameter and support it. (__pthread_cond_timedwait): Pass -1 as clockid. (__pthread_cond_clockwait): New function. (pthread_cond_clockwait): New alias. * sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update prototype. (__pthread_cond_wait): Pass -1 as clockid. * sysdeps/htl/pt-rwlock-timedrdlock.c (__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and support id. (__pthread_rwlock_clockrdlock): New function. (pthread_rwlock_clockrdlock): New alias. * sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update prototype. (__pthread_rwlock_rdlock): Pass -1 as clockid. * sysdeps/htl/pt-rwlock-timedwrlock.c (__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and support id. (__pthread_rwlock_clockwrlock): New function. (pthread_rwlock_clockwrlock): New alias. * sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update prototype. (__pthread_rwlock_wrlock): Pass -1 as clockid. * sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to (__pthread_mutex_clocklock): New function with additional clockid parameter and support it. (pthread_mutex_clocklock): New alias. (__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock. * sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes. * sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype. * htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock, pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np. * sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np, pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np): New functions. * nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c, nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c, nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c, nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c, nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c, nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread. * sysdeps/pthread/tst-mutex8.c: Move back to nptl. * nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust, tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3, tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14, tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ... * sysdeps/pthread/Makefile (tests): ... here.
* signal: Deprecate additional legacy signal handling functionsFlorian Weimer2020-05-257-26/+23
| | | | | | | | | | This needs a few test adjustments: In some cases, sigignore was used for convenience (replaced with xsignal with SIG_IGN). Tests for the deprecated functions need to disable -Wdeprecated-declarations, and for the sigmask deprecation, -Wno-error. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Use __pthread_attr_copy in pthread_setattr_default_npFlorian Weimer2020-05-201-38/+15
| | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)Florian Weimer2020-05-203-9/+82
| | | | | | | pthread_getattr_default_np needs to make a deep copy. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Add __pthread_attr_copy for copying pthread_attr_t objectsFlorian Weimer2020-05-204-0/+65
| | | | | | | | Also add the private type union pthread_attr_transparent, to reduce the amount of casting that is required. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Make __pthread_attr_init, __pthread_attr_destroy available internallyFlorian Weimer2020-05-204-4/+9
| | | | | | | | pthread_attr_destroy needs to be a weak alias to avoid future linknamespace failures. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Move pthread_gettattr_np into libcFlorian Weimer2020-05-204-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Use __getline instead of __getdelim to avoid a localplt failure. Likewise for __getrlimit/getrlimit. The abilist updates were performed by: git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \ | while read x ; do echo "GLIBC_2.32 pthread_getattr_np F" >> $x done python3 scripts/move-symbol-to-libc.py --only-linux pthread_getattr_np The private export of __pthread_getaffinity_np is no longer needed, but the hidden alias still necessary so that the symbol can be exported with versioned_symbol. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Move pthread_getaffinity_np into libcFlorian Weimer2020-05-204-10/+20
| | | | | | | | | | | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> The abilist updates were performed by: git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \ | while read x ; do echo "GLIBC_2.32 pthread_getaffinity_np F" >> $x done python3 scripts/move-symbol-to-libc.py pthread_getaffinity_np Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Move pthread_attr_setaffinity_np into libcFlorian Weimer2020-05-204-10/+29
| | | | | | | | | | | | | | | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> The symbol did not previously exist in libc, so a new GLIBC_2.32 symbol is needed, to get correct dependency for binaries which use the symbol but no longer link against libpthread. The abilist updates were performed by: git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \ | while read x ; do echo "GLIBC_2.32 pthread_attr_setaffinity_np F" >> $x done python3 scripts/move-symbol-to-libc.py pthread_attr_setaffinity_np Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Replace some stubs with the Linux implementationFlorian Weimer2020-05-209-30/+626
| | | | | | | | | | | | | The stubs for pthread_getaffinity_np, pthread_getname_np, pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding tests are moved. After the removal of the NaCl port, nptl is Linux-specific, and the stubs are no longer needed. This effectively reverts commit c76d1ff5149bd03210f2bb8cd64446c51618d016 ("NPTL: Add stubs for Linux-only extension functions."). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: wait for pending setxid request also in detached thread (bug 25942)Andreas Schwab2020-05-121-5/+6
| | | | | | | | | | | | | There is a race between __nptl_setxid and exiting detached thread, which causes a deadlock on stack_cache_lock. The deadlock happens in this state: T1: setgroups -> __nptl_setxid (holding stack_cache_lock, waiting on cmdp->cntr == 0) T2 (detached, exiting): start_thread -> __deallocate_stack (waiting on stack_cache_lock) more threads waiting on stack_cache_lock in pthread_create For non-detached threads, start_thread waits for its own setxid handler to finish before exiting. Do this for detached threads as well.
* nptl/tst-setuid1-static: Improve isolation from system objectsFlorian Weimer2020-04-271-0/+5
| | | | | Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system libraries.
* nptl: Start new threads with all signals blocked [BZ #25098]Florian Weimer2020-04-272-24/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | New threads inherit the signal mask from the current thread. This means that signal handlers can run on the newly created thread immediately after the kernel has created the userspace thread, even before glibc has initialized the TCB. Consequently, new threads can observe uninitialized ctype data, among other things. To address this, block all signals before starting the thread, and pass the original signal mask to the start routine wrapper. On the new thread, first perform all thread initialization, and then unblock signals. The cost of doing this is two rt_sigprocmask system calls on the old thread, and one rt_sigprocmask system call on the new thread. (If there was a way to clone a new thread with a signals disabled, this could be brought down to one system call each.) The thread descriptor increases in size, too, and sigset_t is fairly large. This increase could be brought down by reusing space the in the descriptor which is not needed before running user code, or by switching to an internal sigset_t definition which only covers the signals supported by the kernel definition. (Part of the thread descriptor size increase is already offset by reduced stack usage in the thread start wrapper routine after this commit.) Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* signal: Only handle on NSIG signals on signal functions (BZ #25657)Adhemerval Zanella2020-04-213-5/+66
| | | | | | | | | | | | | | | The upper bits of the sigset_t s not fully initialized in the signal mask calls that return information from kernel (sigprocmask, sigpending, and pthread_sigmask), since the exported sigset_t size (1024 bits) is larger than Linux support one (64 or 128 bits). It might make sigisemptyset/sigorset/sigandset fail if the mask is filled prior the call. This patch changes the internal signal function to handle up to supported Linux signal number (_NSIG), the remaining bits are untouched. Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: Use pthread_sigmask on sigprocmaskAdhemerval Zanella2020-04-212-0/+3
| | | | | | | With pthread_sigmask on libc.so, it allows implement sigprocmask on top of pthread_sigmask. Checked on x86_64-linux-gnu.
* nptl: Move pthread_sigmask implementation to libcAdhemerval Zanella2020-04-213-4/+14
| | | | | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> A new symbol version is added on libc to force loading failure instead of lazy binding one for newly binaries with old loaders. Checked with a build against all affected ABIs.
* Linux: set_robust_list syscall number is always availableFlorian Weimer2020-03-032-8/+2
| | | | | | | Due to the built-in tables, __NR_set_robust_list is always defined (although it may not be available at run time). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_setschedparam implementation into libcFlorian Weimer2020-02-204-9/+1
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_getschedparam implementation into libcFlorian Weimer2020-02-204-6/+3
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_cond_init implementation into libcFlorian Weimer2020-02-207-20/+8
| | | | | | | | | | | It is necessary to export __pthread_cond_init from libc because the C11 condition variable needs it and is still left in libpthread. This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_cond_destroy implementation into libcFlorian Weimer2020-02-207-19/+13
| | | | | | | | | | | It is necessary to export __pthread_cond_destroy from libc because the C11 condition variable needs it and is still left in libpthread. This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_condattr_init implementation into libcFlorian Weimer2020-02-204-6/+1
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_condattr_destroy implementation into libcFlorian Weimer2020-02-204-4/+3
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>