aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/htl
AgeCommit message (Collapse)AuthorFilesLines
2024-12-09htl: move pthread_condattr_destroy into libc.gfleury2-3/+5
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20241126205329.2215295-2-gfleury@disroot.org>
2024-11-19htl: move pthread_attr_init into libc.gfleury3-3/+9
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setguardsize into libc.gfleury1-1/+7
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setschedparam into libc.gfleury2-6/+5
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setscope into libc.gfleury2-3/+5
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstackaddr into libc.gfleury3-3/+16
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_setstacksize into libc.gfleury2-1/+8
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstack into libc.gfleury2-1/+8
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_getstackaddr into libc.gfleury2-1/+8
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getstacksize into libc.gfleury2-1/+8
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getscope into libc.gfleury2-3/+5
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl move pthread_attr_getguardsize into libc.gfleury1-1/+7
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move __pthread_default_attr into libcgfleury1-0/+1
Signed-off-by: gfleury <gfleury@disroot.org>
2024-11-19htl: move pthread_attr_destroy into libc.gfleury2-3/+6
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-08-01hurd: Fix missing pthread_ compat symbol in libcSamuel Thibault10-10/+60
5476f8cd2e68 ("htl: move pthread_self info libc.") and 9dfa2562162b ("htl: move pthread_equal into libc") to 1dc0bc8f0748 ("htl: move pthread_attr_setdetachstate into libc") moved some pthread_ symbols from libpthread.so to libc.so, but missed adding the compat version like 5476f8cd2e68 ("htl: move pthread_self info libc.") did: libc already had these symbols as forwards, but versioned GLIBC_2.21, while the symbols in libpthread.so were versioned GLIBC_2.12. To fix running executables built before this, we thus have to add the GLIBC_2.12 version, otherwise execution fails with e.g. /usr/lib/i386-gnu/libglib-2.0.so: symbol lookup error: /usr/lib/i386-gnu/libglib-2.0.so: undefined symbol: pthread_attr_setinheritsched, version GLIBC_2.12
2024-07-16Add pthread_getname_np and pthread_setname_np for HurdFlavio Cruz1-0/+11
We use thread_get_name and thread_set_name to get and set the thread name, so nothing is stored in the thread structure since these functions are supposed to be called sparingly. One notable difference with Linux is that the thread name is up to 32 chars, whereas Linux's is 16. Also added a mach_RPC_CHECK to check for the existing of gnumach RPCs.
2024-03-23htl: Implement some support for TLS_DTV_AT_TPSergey Bugaev1-2/+14
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240323173301.151066-19-bugaevc@gmail.com>
2024-03-23htl: Respect GL(dl_stack_flags) when allocating stacksSergey Bugaev1-0/+4
Previously, HTL would always allocate non-executable stacks. This has never been noticed, since GNU Mach on x86 ignores VM_PROT_EXECUTE and makes all pages implicitly executable. Since GNU Mach on AArch64 supports non-executable pages, HTL forgetting to pass VM_PROT_EXECUTE immediately breaks any code that (unfortunately, still) relies on executable stacks. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240323173301.151066-7-bugaevc@gmail.com>
2024-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert114-114/+114
2023-08-24htl: move pthread_attr_setdetachstate into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-11-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_getdetachstate into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-10-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_setschedpolicy into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-9-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_getschedpolicy into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-8-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_setinheritsched into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-7-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_getinheritsched into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-6-gfleury@disroot.org>
2023-08-24htl: move pthread_attr_getschedparam into libcGuy-Fleury Iteriteka1-4/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-5-gfleury@disroot.org>
2023-08-24htl: move pthread_setschedparam into libcGuy-Fleury Iteriteka1-4/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-4-gfleury@disroot.org>
2023-08-24htl: move pthread_getschedparam into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-3-gfleury@disroot.org>
2023-08-24htl: move pthread_equal into libcGuy-Fleury Iteriteka1-2/+0
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230716084414.107245-2-gfleury@disroot.org>
2023-08-08htl: Add support for static TSD dataSamuel Thibault7-18/+97
When using jemalloc, malloc() needs to use TSD, while libpthread initialization needs malloc(). Supporting a static TSD area allows jemalloc and libpthread to initialize together.
2023-05-30Fix misspellings in sysdeps/ -- BZ 25337Paul Pluzhnikov8-13/+13
2023-05-20htl: Use __hurd_fail () instead of assigning errnoSergey Bugaev4-18/+9
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230520115531.3911877-2-bugaevc@gmail.com>
2023-05-01hurd 64bit: Fix pthread_t/thread_t type to longSamuel Thibault4-2/+50
So that they can be trivially cast to pointer type, like with nptl.
2023-05-01hurd 64bit: Add missing libanlSamuel Thibault1-0/+1
The move of libanl to libc was in glibc 2.34 for nptl only.
2023-04-05htl: move pthread_self info libc.Guy-Fleury Iteriteka2-2/+2
Signed-off-by: Guy-Fleury Iteriteka <gfleury@disroot.org> Message-Id: <20230318095826.1125734-4-gfleury@disroot.org>
2023-02-12htl: Remove ./sysdeps/htl/bits/types/struct___pthread_mutex.hSamuel Thibault1-61/+0
This follows a99155555c21 ("htl: Remove unused files")
2023-02-12htl: Fix semaphore referenceSergey Bugaev1-5/+5
'sem' is the opaque 'sem_t', 'isem' is the actual 'struct new_sem'. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230212111044.610942-6-bugaevc@gmail.com>
2023-01-06Update copyright dates with scripts/update-copyrightsJoseph Myers113-113/+113
2022-12-30htl: Fix sem_wait race between read and gsync_waitSamuel Thibault1-2/+2
If the value changes between sem_wait's read and the gsync_wait call, the kernel will return KERN_INVALID_ARGUMENT, which we have to interpret as the value having already changed. This fixes applications (e.g. libgo) seeing sem_wait erroneously return KERN_INVALID_ARGUMENT.
2022-08-22htl: Make pthread*_cond_timedwait register wref before releasing mutexSamuel Thibault1-4/+6
Otherwise another thread could be rightly trying to destroy the condition, see e.g. tst-cond20.
2022-02-14htl: Fix initializing the key lockSamuel Thibault2-3/+5
The static pthread_once_t in the pt-key.h header was creating one pthread_once_t per includer. We have to use a shared common pthread_once_t instead.
2022-02-14htl: Make pthread_[gs]etspecific not check for key validitySamuel Thibault2-4/+2
Since __pthread_key_create might be concurrently reallocating the __pthread_key_destructors array, it's not safe to access it without the mutex held. Posix explicitly says we are allowed to prefer performance over error detection.
2022-01-17htl: Fix build error in annexcSamuel Thibault1-2/+4
We were getting ../scripts/evaluate-test.sh posix/annexc $? true false > /usr/src/glibc-upstream/build/posix/annexc.test-result In file included from ../include/pthread.h:1, from <stdin>:1: ../sysdeps/htl/include/pthread.h:7:62: error: missing binary operator before token "(" 7 | # if defined __USE_EXTERN_INLINES && defined _LIBC && !IS_IN (libsupport) | ^
2022-01-15htl: Hide __pthread_attr's __schedparam type [BZ #23088]Samuel Thibault5-9/+11
The content of the structure is only used internally, so we can make __pthread_attr_getschedparam and __pthread_attr_setschedparam convert between the public sched_param type and an internal __sched_param. This allows to avoid to spuriously expose the sched_param type. This fixes BZ #23088.
2022-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert113-113/+113
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: Reimplement GSCOPESergey Bugaev1-0/+55
This is a new implementation of GSCOPE which largely mirrors its NPTL counterpart. Same as in NPTL, instead of a global flag shared between threads, there is now a per-thread GSCOPE flag stored in each thread's TCB. This makes entering and exiting a GSCOPE faster at the expense of making THREAD_GSCOPE_WAIT () slower. The largest win is the elimination of many redundant gsync_wake () RPC calls; previously, even simplest programs would make dozens of fully redundant gsync_wake () calls. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20210915171110.226187-3-bugaevc@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-09-16htl: Move thread table to ld.soSergey Bugaev5-8/+40
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-09-03Remove "Contributed by" linesSiddhesh Poyarekar2-2/+0
We stopped adding "Contributed by" or similar lines in sources in 2012 in favour of git logs and keeping the Contributors section of the glibc manual up to date. Removing these lines makes the license header a bit more consistent across files and also removes the possibility of error in attribution when license blocks or files are copied across since the contributed-by lines don't actually reflect reality in those cases. Move all "Contributed by" and similar lines (Written by, Test by, etc.) into a new file CONTRIBUTED-BY to retain record of these contributions. These contributors are also mentioned in manual/contrib.texi, so we just maintain this additional record as a courtesy to the earlier developers. The following scripts were used to filter a list of files to edit in place and to clean up the CONTRIBUTED-BY file respectively. These were not added to the glibc sources because they're not expected to be of any use in future given that this is a one time task: https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-07-18htl: Do not expose pthread hidden proto outside libpthreadSamuel Thibault1-3/+3
Only libpthread.so can access them.