]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
runtime: For c-archive/c-shared, install signal handlers synchronously.
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 12 Feb 2016 22:10:09 +0000 (22:10 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 12 Feb 2016 22:10:09 +0000 (22:10 +0000)
    This is a port of https://golang.org/cl/18150 to the gccgo runtime.

    The previous behaviour of installing the signal handlers in a separate
    thread meant that Go initialization raced with non-Go initialization if
    the non-Go initialization also wanted to install signal handlers.  Make
    installing signal handlers synchronous so that the process-wide behavior
    is predictable.

    Reviewed-on: https://go-review.googlesource.com/19494

From-SVN: r233393

gcc/go/gofrontend/MERGE
libgo/runtime/go-libmain.c
libgo/runtime/proc.c
libgo/runtime/runtime.h
libgo/runtime/signal_unix.c

index fee516838cb21676b11632dfb65dddba3af29d63..228dfc1360a426e5623550aad921ac171a0df44b 100644 (file)
@@ -1,4 +1,4 @@
-28a9dfbc3cda0bf7fd4f3fb1506c547f6cdf41a5
+22278c6e8ce3982b09111183bc6addf0184bef1f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index f578aab43b7f244b4e66ff1302a6aabc44c264c8..6884f3a5f56d796271ebe70f16f0f46e018c6094 100644 (file)
@@ -59,6 +59,10 @@ initfn (int argc, char **argv, char** env __attribute__ ((unused)))
   struct args *a;
   pthread_t tid;
 
+  runtime_isarchive = true;
+
+  runtime_initsig(true);
+
   a = (struct args *) malloc (sizeof *a);
   if (a == NULL)
     die ("malloc", errno);
@@ -88,8 +92,6 @@ gostart (void *arg)
 {
   struct args *a = (struct args *) arg;
 
-  runtime_isarchive = true;
-
   if (runtime_isstarted)
     return NULL;
   runtime_isstarted = true;
index cd926b4ea62e19bfff9ae7b9007e43767ce1f2b3..9ba199b8caea2f9c9ef95a219728af987dd442fd 100644 (file)
@@ -1093,7 +1093,7 @@ runtime_mstart(void* mp)
                        runtime_newextram();
                        runtime_needextram = 0;
                }
-               runtime_initsig();
+               runtime_initsig(false);
        }
        
        if(m->mstartfn)
index 34143e9a256f54a16fcd588f8540880a8642702e..73c46e9117f646a432dc31cd15f3d3d4d21376ec 100644 (file)
@@ -550,7 +550,7 @@ void*       runtime_mal(uintptr);
 String runtime_gostring(const byte*);
 String runtime_gostringnocopy(const byte*);
 void   runtime_schedinit(void);
-void   runtime_initsig(void);
+void   runtime_initsig(bool);
 void   runtime_sigenable(uint32 sig);
 void   runtime_sigdisable(uint32 sig);
 void   runtime_sigignore(uint32 sig);
index 20289335f8dc5835a8a4a0a7810f06ab4ae9a6f5..5bee0d2a70605ac0fe9488e30dc34f41b6d50440 100644 (file)
 extern SigTab runtime_sigtab[];
 
 void
-runtime_initsig(void)
+runtime_initsig(bool preinit)
 {
        int32 i;
        SigTab *t;
 
+       // For c-archive/c-shared this is called by go-libmain.c with
+       // preinit == true.
+       if(runtime_isarchive && !preinit)
+               return;
+
        // First call: basic setup.
        for(i = 0; runtime_sigtab[i].sig != -1; i++) {
                t = &runtime_sigtab[i];
@@ -37,6 +42,9 @@ runtime_initsig(void)
                        }
                }
 
+               if(runtime_isarchive && (t->flags&SigPanic) == 0)
+                       continue;
+
                t->flags |= SigHandling;
                runtime_setsig(i, runtime_sighandler, true);
        }