diff mbox

libgo patch committed: Ignore SIGPROF on non-Go thread

Message ID mcrsiz5dh03.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor July 23, 2013, 4:42 a.m. UTC
This patch to libgo ignores a SIGPROF signal if it is received on a
non-Go thread.  This permits the Go library profiling support to work in
a program that calls C/C++ code that starts threads.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and
4.8 branch.

Ian
diff mbox

Patch

diff -r f1650653ba7d libgo/runtime/go-signal.c
--- a/libgo/runtime/go-signal.c	Tue Jul 16 15:42:30 2013 -0700
+++ b/libgo/runtime/go-signal.c	Mon Jul 22 21:39:43 2013 -0700
@@ -166,21 +166,22 @@ 
   int i;
 
   m = runtime_m ();
+
+#ifdef SIGPROF
+  if (sig == SIGPROF)
+    {
+      if (m != NULL && gp != m->g0 && gp != m->gsignal)
+	runtime_sigprof ();
+      return;
+    }
+#endif
+
   if (m == NULL)
     {
       runtime_badsignal (sig);
       return;
     }
 
-#ifdef SIGPROF
-  if (sig == SIGPROF)
-    {
-      if (gp != runtime_m ()->g0 && gp != runtime_m ()->gsignal)
-	runtime_sigprof ();
-      return;
-    }
-#endif
-
   for (i = 0; runtime_sigtab[i].sig != -1; ++i)
     {
       SigTab *t;