public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] htl: make pthread_sigstate read/write set/oset outside sigstate section
@ 2021-09-25 23:05 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2021-09-25 23:05 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1cc205c510dedb9795103e728e4b8aeee83cbd53

commit 1cc205c510dedb9795103e728e4b8aeee83cbd53
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Sep 26 01:02:54 2021 +0200

    htl: make pthread_sigstate read/write set/oset outside sigstate section
    
    so that if a segfault occurs, the handler can run fine.

Diff:
---
 sysdeps/mach/hurd/htl/pt-sigstate.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-25 23:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25 23:05 [glibc] htl: make pthread_sigstate read/write set/oset outside sigstate section Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).