emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113142: Try to avoid malloc SEGVs on Cygwin.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113142: Try to avoid malloc SEGVs on Cygwin.
Date: Sun, 23 Jun 2013 18:18:51 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113142
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/14569
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2013-06-23 11:18:47 -0700
message:
  Try to avoid malloc SEGVs on Cygwin.
  
  * callproc.c, process.h (block_child_signal, unblock_child_signal):
  Now extern.
  * emacs.c (main): Catch SIGCHLD just before initializing gfilenotify.
  * process.c (catch_child_signal): Block SIGCHLD while futzing with
  the SIGCHLD handler, since the code is not atomic and (due to glib)
  signals may be arriving now.
  * sysdep.c (init_signals): Do not catch child signals here;
  'main' now does that later, at a safer time.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/callproc.c                 callproc.c-20091113204419-o5vbwnq5f7feedwu-248
  src/emacs.c                    emacs.c-20091113204419-o5vbwnq5f7feedwu-241
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
  src/process.h                  process.h-20091113204419-o5vbwnq5f7feedwu-272
  src/sysdep.c                   sysdep.c-20091113204419-o5vbwnq5f7feedwu-448
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-06-22 19:01:47 +0000
+++ b/src/ChangeLog     2013-06-23 18:18:47 +0000
@@ -1,3 +1,15 @@
+2013-06-23  Paul Eggert  <address@hidden>
+
+       Try to avoid malloc SEGVs on Cygwin (Bug#14569).
+       * callproc.c, process.h (block_child_signal, unblock_child_signal):
+       Now extern.
+       * emacs.c (main): Catch SIGCHLD just before initializing gfilenotify.
+       * process.c (catch_child_signal): Block SIGCHLD while futzing with
+       the SIGCHLD handler, since the code is not atomic and (due to glib)
+       signals may be arriving now.
+       * sysdep.c (init_signals): Do not catch child signals here;
+       'main' now does that later, at a safer time.
+
 2013-06-22  Paul Eggert  <address@hidden>
 
        Clean up SIGCHLD handling a bit (Bug#14569).

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2013-05-25 01:55:00 +0000
+++ b/src/callproc.c    2013-06-23 18:18:47 +0000
@@ -84,7 +84,7 @@
 
 /* Block SIGCHLD.  */
 
-static void
+void
 block_child_signal (void)
 {
   sigset_t blocked;
@@ -95,7 +95,7 @@
 
 /* Unblock SIGCHLD.  */
 
-static void
+void
 unblock_child_signal (void)
 {
   pthread_sigmask (SIG_SETMASK, &empty_mask, 0);

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2013-06-17 06:03:19 +0000
+++ b/src/emacs.c       2013-06-23 18:18:47 +0000
@@ -1257,6 +1257,13 @@
     tzset ();
 #endif /* MSDOS */
 
+  /* Do this after initializing the memory allocator, since it uses
+     glib and glib uses malloc.  And do it before anything else that
+     invokes glib, to avoid potential races among glib subthreads in
+     Cygwin glib.  gfilenotify invokes glib, so this can't be delayed
+     further.  */
+  catch_child_signal ();
+
 #ifdef HAVE_GFILENOTIFY
   globals_of_gfilenotify ();
 #endif

=== modified file 'src/process.c'
--- a/src/process.c     2013-06-22 19:01:47 +0000
+++ b/src/process.c     2013-06-23 18:18:47 +0000
@@ -7084,11 +7084,13 @@
 #endif
 
   emacs_sigaction_init (&action, deliver_child_signal);
+  block_child_signal ();
   sigaction (SIGCHLD, &action, &old_action);
   eassert (! (old_action.sa_flags & SA_SIGINFO));
   if (old_action.sa_handler != SIG_DFL && old_action.sa_handler != SIG_IGN
       && old_action.sa_handler != deliver_child_signal)
     lib_child_handler = old_action.sa_handler;
+  unblock_child_signal ();
 }
 
 

=== modified file 'src/process.h'
--- a/src/process.h     2013-06-22 19:01:47 +0000
+++ b/src/process.h     2013-06-23 18:18:47 +0000
@@ -200,6 +200,8 @@
 
 /* Defined in callproc.c.  */
 
+extern void block_child_signal (void);
+extern void unblock_child_signal (void);
 extern void record_kill_process (struct Lisp_Process *);
 
 /* Defined in process.c.  */

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2013-06-22 19:01:47 +0000
+++ b/src/sysdep.c      2013-06-23 18:18:47 +0000
@@ -1901,8 +1901,6 @@
       sigaction (SIGFPE, &action, 0);
     }
 
-  catch_child_signal ();
-
 #ifdef SIGUSR1
   add_user_signal (SIGUSR1, "sigusr1");
 #endif


reply via email to

[Prev in Thread] Current Thread [Next in Thread]