[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd, commited 2/4] htl: Keep thread signals blocked during its initial
From: |
Samuel Thibault |
Subject: |
[hurd, commited 2/4] htl: Keep thread signals blocked during its initialization |
Date: |
Wed, 11 Nov 2020 21:43:14 +0100 |
One may send signals immediately after creating a thread. We need to block them
until the thread is ready to run signal handlers.
---
htl/pt-create.c | 12 ++++++++++--
htl/pt-internal.h | 3 +++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/htl/pt-create.c b/htl/pt-create.c
index 7ac875cbf7..9364c40453 100644
--- a/htl/pt-create.c
+++ b/htl/pt-create.c
@@ -46,6 +46,8 @@ unsigned int __pthread_total;
static void
entry_point (struct __pthread *self, void *(*start_routine) (void *), void
*arg)
{
+ int err;
+
___pthread_self = self;
__resp = &self->res_state;
@@ -60,6 +62,10 @@ entry_point (struct __pthread *self, void *(*start_routine)
(void *), void *arg)
__pthread_startup ();
+ /* We can now unleash signals. */
+ err = __pthread_sigstate (self, SIG_SETMASK, &self->init_sigset, 0, 0);
+ assert_perror (err);
+
if (self->c11)
{
/* The function pointer of the c11 thread start is cast to an incorrect
@@ -201,11 +207,13 @@ __pthread_create_internal (struct __pthread **thread,
shall be empty." If the currnet thread is not a pthread then we
just inherit the process' sigmask. */
if (__pthread_num_threads == 1)
- err = __sigprocmask (0, 0, &sigset);
+ err = __sigprocmask (0, 0, &pthread->init_sigset);
else
- err = __pthread_sigstate (_pthread_self (), 0, 0, &sigset, 0);
+ err = __pthread_sigstate (_pthread_self (), 0, 0, &pthread->init_sigset,
0);
assert_perror (err);
+ /* But block the signals for now, until the thread is fully initialized. */
+ __sigfillset (&sigset);
err = __pthread_sigstate (pthread, SIG_SETMASK, &sigset, 0, 1);
assert_perror (err);
diff --git a/htl/pt-internal.h b/htl/pt-internal.h
index e0baa6bcda..9dffa0e32e 100644
--- a/htl/pt-internal.h
+++ b/htl/pt-internal.h
@@ -102,6 +102,9 @@ struct __pthread
/* Indicates whether is a C11 thread created by thrd_creat. */
bool c11;
+ /* Initial sigset for the thread. */
+ sigset_t init_sigset;
+
/* Thread context. */
struct pthread_mcontext mcontext;
--
2.28.0
- [hurd,commited 0/4] Fix more hurd initialization for ifunc support, Samuel Thibault, 2020/11/11
- [hurd, commited 4/4] hurd: Notify the proc server later during initialization, Samuel Thibault, 2020/11/11
- [hurd,commited 1/4] htl: Fix spurious symbols in namespaces, Samuel Thibault, 2020/11/11
- [hurd, commited 2/4] htl: Keep thread signals blocked during its initialization,
Samuel Thibault <=
- [hurd,commited 3/4] htl: Initialize later, Samuel Thibault, 2020/11/11