public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [FYI][PATCH] libgo/runtime: S/390: Workaround for broken setcontext in Gcc.
@ 2015-09-01  8:18 Dominik Vogt
  0 siblings, 0 replies; only message in thread
From: Dominik Vogt @ 2015-09-01  8:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

The attached patch is a workaround for a Bug in Glibc versions on S/390
where setcontext() screws up the processes signal mask.  The patch is
meant to be an optional addon for people who need it.  Please check the
commit comment in the patch for a detailed description.

** Please do NOT apply this patch. **

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-libgo-runtime-S-390-Workaround-for-broken-setcontext-v1.patch --]
[-- Type: text/x-diff, Size: 1341 bytes --]

From 0ef4dea9441ea53f12040a2e59699b93f1e3913d Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Mon, 31 Aug 2015 16:21:28 +0100
Subject: [PATCH] libgo/runtime: S/390: Workaround for broken setcontext in
 Glibc.

In Glibc versions before 2.22, the setcontext() function screws up the signal
mask.  See commit:
2e807f29595eb5b1e5d0decc6e356a3562ecc58e (https://ibm.biz/BdXwPB)

One symptom of this bug is that Docker processes start with blocked signals
and e.g. SIGINT is not delivered.  This patch works around the Glibc bug in
Gccgo at the cost of an additional syscall for each invocation of setcontext().
---
 libgo/runtime/proc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index babad01..c6cafa6 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -21,6 +21,17 @@
 #include "go-type.h"
 #include "go-defer.h"
 
+#ifdef __s390__
+// This is a workaround for older Glibc versions where setcontext screwed up the
+// signal mask.
+# define setcontext(UCP)				\
+  __extension__ ({					\
+      /* Note: On S/390, setcontext never fails.  */	\
+      sigprocmask(SIG_SETMASK, &(UCP)->uc_sigmask, 0);	\
+      setcontext(UCP);					\
+    })
+#endif
+
 #ifdef USING_SPLIT_STACK
 
 /* FIXME: These are not declared anywhere.  */
-- 
2.3.0


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

only message in thread, other threads:[~2015-09-01  8:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-01  8:18 [FYI][PATCH] libgo/runtime: S/390: Workaround for broken setcontext in Gcc Dominik Vogt

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).