all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: mituharu@math.s.chiba-u.ac.jp
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: 28630@debbugs.gnu.org, tom@tromey.com, agrambot@gmail.com
Subject: bug#28630: 27.0.50; C-g while a non-main thread is sitting crashes Emacs
Date: Mon, 9 Oct 2017 19:34:28 +0900	[thread overview]
Message-ID: <c537db12f0f40f1ddf2b243a7ad4f0df.squirrel@weber.math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <838tgksol2.fsf@gnu.org>

>> In principle, the method I used for the Mac port is also applicable to
>> X11 (but probably not for NS where secondary threads cannot read
>> keyboard input).  Each pselect call not involving keyboard input
>> additionally monitors one side of a socket pair, and the SIGALRM
>> handler writes to the other side.  This way, a pselect call in a
>> secondary thread is unblocked when the signal arrived, and then it
>> tries to see if keyboard input is available when none of other threads
>> is monitoring the keyboard input channel.
>
> But the problematic part in these examples is that the main thread
> always waits for keyboard input, because the non-main thread starts
> running only when the main thread becomes idle, and becoming idle
> means calling pselect.  And since the main thread is always the first
> one to call pselect, it is the thread which finds the keyboard
> descriptor unmonitored, and installs itself as its monitoring thread.
>
> So with your proposal, more often than not, the "none of other threads
> is monitoring the keyboard input channel" part will never be true,
> except for the main thread.  Or am I missing something?

In both Examples, the main thread is not blocking at pselect, but
thread-join (sys_cond_wait internally), i.e., without monitoring
the keyboard descriptor. The secondary one is blocking at pselect
in sit-for (Example 1) or sleep-for (Example 2).  So "none of
other threads is monitoring the keyboard input channel" part
becomes true for the secondary thread after returning from
pselect.

In Example 2, no thread is monitoring the keyboard while the
secondary thread is blocking at pselect, and that is why the Mac
port could not be interrupted with C-g previously.  I think this
basically also applies to X11.  For GTK+ cases, my guess is the
additionally monitored descriptors obtained by
g_main_context_query has something to do with its peculiar
behavior.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp






  reply	other threads:[~2017-10-09 10:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28  7:22 bug#28630: 27.0.50; C-g while a non-main thread is sitting crashes Emacs Alex
2017-10-01  3:18 ` Alex
2017-10-01 15:01   ` Eli Zaretskii
2017-10-01 18:10     ` Alex
2017-10-01 18:32       ` Eli Zaretskii
2017-10-02  4:30         ` YAMAMOTO Mitsuharu
2017-10-02 12:43           ` YAMAMOTO Mitsuharu
2017-10-02 16:08             ` Eli Zaretskii
2017-10-04  7:39               ` Eli Zaretskii
2017-10-04  7:49                 ` YAMAMOTO Mitsuharu
2017-10-04  8:16                   ` Eli Zaretskii
2017-10-04  8:32                     ` YAMAMOTO Mitsuharu
2017-10-04  9:23                       ` Eli Zaretskii
2017-10-05  3:27                         ` YAMAMOTO Mitsuharu
2017-10-05  7:24                           ` Eli Zaretskii
2017-10-07 13:53                             ` Philipp Stephani
2017-10-07 14:24                               ` Eli Zaretskii
2017-10-07 14:50                                 ` Eli Zaretskii
2017-10-09  8:21                             ` YAMAMOTO Mitsuharu
2017-10-09  8:38                               ` Eli Zaretskii
2017-10-09 10:34                                 ` mituharu [this message]
2017-10-09 11:01                                   ` Eli Zaretskii
2017-10-04  7:39               ` YAMAMOTO Mitsuharu
2017-10-04  8:14                 ` Eli Zaretskii
2017-10-02  5:11         ` Eric Abrahamsen
2017-10-02 15:54           ` Eli Zaretskii
2017-10-03  9:35         ` Dmitry Gutov
2017-10-03 14:38           ` Eli Zaretskii
2017-10-03 14:50             ` Philipp Stephani
2017-10-03 15:45               ` Eli Zaretskii
2017-10-03 16:22                 ` Philipp Stephani
2017-10-03 16:35                   ` Eli Zaretskii
2017-10-03 17:04                     ` Philipp Stephani
2017-10-01 10:08 ` Alan Third
2017-10-01 15:03   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c537db12f0f40f1ddf2b243a7ad4f0df.squirrel@weber.math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=28630@debbugs.gnu.org \
    --cc=agrambot@gmail.com \
    --cc=eliz@gnu.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.