[Top][All Lists]

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

bug#14569: 24.3.50; bootstrap fails on Cygwin

From: Paul Eggert
Subject: bug#14569: 24.3.50; bootstrap fails on Cygwin
Date: Fri, 14 Jun 2013 10:45:47 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

Cygwin developers, I'm worried about a Cygwin bug where
pthread_kill may not send a signal to the correct thread.
This bug may be causing Emacs to crash.  The Cygwin bug is
discussed in this thread:


Emacs uses pthread_kill to redirect
SIGCHLD to the main thread; if this is sent to a random
thread instead, that could explain the random crashes.

My question is: does this bug still exist with Cygwin,
and if so is it likely to get fixed soon?

More details about the Emacs bug can be found here:


Briefly, Emacs is crashing randomly on Cygwin ever since it started
doing this:

  /* Tickle glib's child-handling code.  Ask glib to wait for Emacs itself;
     this should always fail, but is enough to initialize glib's            
     private SIGCHLD handler.  */
  g_source_unref (g_child_watch_source_new (getpid ()));

After this newly-inserted code, Emacs finds out what the
child signal handler was:

  /* Now, find out what glib's signal handler was, and store it
     into lib_child_handler.  */
  struct sigaction action, old_action;
  emacs_sigaction_init (&action, deliver_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;

Emacs's SIGCHILD handler, deliver_child_signal, arranges the
signal handling to occur in the main thread (to avoid races
within Emacs), like this:

  int old_errno = errno;
  bool on_main_thread = true;
  if (! pthread_equal (pthread_self (), main_thread))
      sigset_t blocked;
      sigemptyset (&blocked);
      sigaddset (&blocked, sig);
      pthread_sigmask (SIG_BLOCK, &blocked, 0);
      pthread_kill (main_thread, sig);
      on_main_thread = false;
  if (on_main_thread)
    handle_child_signal (sig);
  errno = old_errno;

And handle_child_signal, which runs in the main thread, does
a bunch of Emacsish things and then invokes lib_child_handler (sig),
which is glib's SIGCHLD handler.

All this works just fine on Fedora and other platforms; but it
doesn't work on Cygwin.

reply via email to

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