aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/htl/pthreadP.h
AgeCommit message (Collapse)AuthorFilesLines
2025-04-02stdlib: Fix qsort memory leak if callback throws (BZ 32058)Adhemerval Zanella1-0/+15
If the input buffer exceeds the stack auxiliary buffer, qsort will malloc a temporary one to call mergesort. Since C++ standard does allow the callback comparison function to throw [1], the glibc implementation can potentially leak memory. The fixes uses a pthread_cleanup_combined_push and pthread_cleanup_combined_pop, so it can work with and without exception enables. The qsort code path that calls malloc now requires some extra setup and a call to __pthread_cleanup_push anmd __pthread_cleanup_pop (which should be ok since they just setup some buffer state). Checked on x86_64-linux-gnu. [1] https://timsong-cpp.github.io/cppwp/n4950/alg.c.library#4 Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-15htl: Make pthread_setcanceltype / state a cancellation pointSamuel Thibault1-0/+8
as expected by tst-cancel32.
2025-02-16htl: move pthread_rwlock_{rdlock, timedrdlock, timedwrlock, wrlock, ↵gfleury1-0/+12
clockrdlock, clockwrlock} into libc. Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-8-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared into ↵gfleury1-0/+6
libc. Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-5-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_destroy into libc.gfleury1-0/+2
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-4-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_init into libc.gfleury1-0/+2
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-3-gfleury@disroot.org>
2025-02-10htl: move pthread_barrier_wait into libc.gfleury1-0/+2
Message-ID: <20250209200108.865599-8-gfleury@disroot.org>
2025-02-10htl: move pthread_barrier_init into libc.gfleury1-0/+4
Message-ID: <20250209200108.865599-7-gfleury@disroot.org>
2025-02-10htl: move pthread_barrier_destroy into libc.gfleury1-0/+2
Message-ID: <20250209200108.865599-6-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_getpshared, pthread_barrierattr_setpshared ↵gfleury1-0/+6
into libc. Message-ID: <20250209200108.865599-5-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_init into libc.gfleury1-0/+2
Message-ID: <20250209200108.865599-4-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_destroy into libc.gfleury1-0/+2
Message-ID: <20250209200108.865599-3-gfleury@disroot.org>
2025-02-01htl: move pthread_setcancelstate into libc.gfleury1-2/+0
sysdeps/pthread/sem_open.c: call pthread_setcancelstate directely since forward declaration is gone on hurd too Message-ID: <20250201080202.494671-1-gfleury@disroot.org>
2025-01-29htl: move pthread_setcanceltype into libc.gfleury1-0/+3
Message-ID: <20250103103750.870897-7-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_consistent, pthread_mutex_consistent_np into libc.gfleury1-0/+2
Message-ID: <20250103103750.870897-6-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_destroy into libc.gfleury1-2/+0
Message-ID: <20250103103750.870897-5-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_getprioceiling, pthread_mutex_setprioceiling into libcgfleury1-0/+6
Message-ID: <20250103103750.870897-4-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_{lock, unlock, trylock, timedlock, clocklock}gfleury1-4/+7
I haven't exposed _pthread_mutex_lock, _pthread_mutex_trylock and _pthread_mutex_unlock in GLIBC_PRIVATE since there aren't used in any code in libpthread Message-ID: <20250103103750.870897-3-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_init into libc.gfleury1-1/+1
Message-ID: <20250103103750.870897-2-gfleury@disroot.org>
2025-01-29htl: remove leftover for pthread_mutexattr_settypegfleury1-1/+0
from b386295727d35a83aa3d4750e198cbf8040c9a23
2025-01-02htl: move pthread_mutexattr_setprioceiling, pthread_mutexattr_getprioceiling ↵gfleury1-0/+7
into libc. Message-ID: <20241231134909.1166440-9-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_{setrobust, setrobust_np}, ↵gfleury1-0/+16
pthread_mutexattr_{getrobust, getrobust_np} into libc. Message-ID: <20241231134909.1166440-8-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_setpshared, pthread_mutexattr_getpshared into libc.gfleury1-0/+6
Message-ID: <20241231134909.1166440-7-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_settype, pthread_mutexattr_gettype into libc.gfleury1-0/+7
Message-ID: <20241231134909.1166440-6-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_setprotocol into libc.Samuel Thibault1-0/+4
Message-ID: <20241231134909.1166440-5-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_getprotocol into libc.gfleury1-0/+3
Message-ID: <20241231134909.1166440-4-gfleury@disroot.org>
2025-01-01htl: move pthread_mutexattr_init into libc.gfleury1-1/+0
Message-ID: <20241231134909.1166440-2-gfleury@disroot.org>
2025-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert1-1/+1
2024-12-22htl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait ↵gfleury1-0/+3
into libc. Message-ID: <20241219203727.669825-9-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_signal into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-6-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_broadcast into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-5-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_destroy into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-4-gfleury@disroot.org>
2024-12-22htl: move pthread_cond_init into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241219203727.669825-2-gfleury@disroot.org>
2024-12-14htl: move pthread_sigmask into libc.gfleury1-0/+2
Message-ID: <20241212220612.782313-3-gfleury@disroot.org>
2024-12-09htl: move pthread_condattr_init into libc.gfleury1-0/+2
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-6-gfleury@disroot.org>
2024-11-19htl: move pthread_attr_init into libc.gfleury1-0/+2
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstackaddr into libc.gfleury1-0/+2
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstacksize into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstack into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstackaddr into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getstacksize into libc.gfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-10-08stdlib: Make abort/_Exit AS-safe (BZ 26275)Adhemerval Zanella1-0/+2
The recursive lock used on abort does not synchronize with a new process creation (either by fork-like interfaces or posix_spawn ones), nor it is reinitialized after fork(). Also, the SIGABRT unblock before raise() shows another race condition, where a fork or posix_spawn() call by another thread, just after the recursive lock release and before the SIGABRT signal, might create programs with a non-expected signal mask. With the default option (without POSIX_SPAWN_SETSIGDEF), the process can see SIG_DFL for SIGABRT, where it should be SIG_IGN. To fix the AS-safe, raise() does not change the process signal mask, and an AS-safe lock is used if a SIGABRT is installed or the process is blocked or ignored. With the signal mask change removal, there is no need to use a recursive loc. The lock is also taken on both _Fork() and posix_spawn(), to avoid the spawn process to see the abort handler as SIG_DFL. A read-write lock is used to avoid serialize _Fork and posix_spawn execution. Both sigaction (SIGABRT) and abort() requires to lock as writer (since both change the disposition). The fallback is also simplified: there is no need to use a loop of ABORT_INSTRUCTION after _exit() (if the syscall does not terminate the process, the system is broken). The proposed fix changes how setjmp works on a SIGABRT handler, where glibc does not save the signal mask. So usage like the below will now always abort. static volatile int chk_fail_ok; static jmp_buf chk_fail_buf; static void handler (int sig) { if (chk_fail_ok) { chk_fail_ok = 0; longjmp (chk_fail_buf, 1); } else _exit (127); } [...] signal (SIGABRT, handler); [....] chk_fail_ok = 1; if (! setjmp (chk_fail_buf)) { // Something that can calls abort, like a failed fortify function. chk_fail_ok = 0; printf ("FAIL\n"); } Such cases will need to use sigsetjmp instead. The _dl_start_profile calls sigaction through _profil, and to avoid pulling abort() on loader the call is replaced with __libc_sigaction. Checked on x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert1-1/+1
2023-04-05htl: move pthread_self info libc.Guy-Fleury Iteriteka1-0/+2
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-4-gfleury@disroot.org>
2023-01-06Update copyright dates with scripts/update-copyrightsJoseph Myers1-1/+1
2022-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert1-1/+1
I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2021-09-16htl: Move thread table to ld.soSergey Bugaev1-2/+0
The next commit is going to introduce a new implementation of THREAD_GSCOPE_WAIT which needs to access the list of threads. Since it must be usable from the dynamic laoder, we have to move the symbols for the list of threads into the loader. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20210915171110.226187-2-bugaevc@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-07-18htl: Do not expose pthread hidden proto outside libpthreadSamuel Thibault1-3/+3
Only libpthread.so can access them.
2021-07-13htl: Let libc call __pthread_mutex_{,try,un}lockSamuel Thibault1-0/+3
Now that NPTL was moved to libc, libc makes internal __pthread calls, so htl has to expose them internally.
2021-06-09nptl: Implement raise in terms of pthread_killAdhemerval Zanella1-2/+0
Now that pthread_kill is provided by libc.so it is possible to implement the generic POSIX implementation as 'pthread_kill(pthread_self(), sig)'. For Linux implementation, pthread_kill read the targeting TID from the TCB. For raise, this it not possible because it would make raise fail when issue after vfork (where creates the resulting process has a different TID from the parent, but its TCB is not updated as for pthread_create). To make raise use pthread_kill, it is make usable from vfork by getting the target thread id through gettid syscall. Checked on x86_64-linux-gnu and aarch64-linux-gnu.