htl: make pthread_sigstate read/write set/oset outside sigstate section

so that if a segfault occurs, the handler can run fine.
This commit is contained in:
Samuel Thibault 2021-09-26 01:02:54 +02:00
parent 15e6d6785a
commit 1cc205c510
1 changed files with 11 additions and 5 deletions

View File

@ -30,30 +30,33 @@ __pthread_sigstate (struct __pthread *thread, int how,
{ {
error_t err = 0; error_t err = 0;
struct hurd_sigstate *ss; struct hurd_sigstate *ss;
sigset_t old, new;
sigset_t pending; sigset_t pending;
if (set != NULL)
new = *set;
ss = _hurd_thread_sigstate (thread->kernel_thread); ss = _hurd_thread_sigstate (thread->kernel_thread);
assert (ss); assert (ss);
_hurd_sigstate_lock (ss); _hurd_sigstate_lock (ss);
if (oset != NULL) old = ss->blocked;
*oset = ss->blocked;
if (set != NULL) if (set != NULL)
{ {
switch (how) switch (how)
{ {
case SIG_BLOCK: case SIG_BLOCK:
ss->blocked |= *set; ss->blocked |= new;
break; break;
case SIG_SETMASK: case SIG_SETMASK:
ss->blocked = *set; ss->blocked = new;
break; break;
case SIG_UNBLOCK: case SIG_UNBLOCK:
ss->blocked &= ~*set; ss->blocked &= ~new;
break; break;
default: default:
@ -69,6 +72,9 @@ __pthread_sigstate (struct __pthread *thread, int how,
pending = _hurd_sigstate_pending (ss) & ~ss->blocked; pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
_hurd_sigstate_unlock (ss); _hurd_sigstate_unlock (ss);
if (!err && oset != NULL)
*oset = old;
if (!err && pending) if (!err && pending)
/* Send a message to the signal thread so it /* Send a message to the signal thread so it
will wake up and check for pending signals. */ will wake up and check for pending signals. */