all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
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: Wed, 04 Oct 2017 11:14:26 +0300	[thread overview]
Message-ID: <83bmlnz5wd.fsf@gnu.org> (raw)
In-Reply-To: <wlk20bnyz4.wl%mituharu@math.s.chiba-u.ac.jp> (message from YAMAMOTO Mitsuharu on Wed, 04 Oct 2017 16:39:27 +0900)

> Date: Wed, 04 Oct 2017 16:39:27 +0900
> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
> Cc: 	28630@debbugs.gnu.org,
> 	tom@tromey.com,
> 	agrambot@gmail.com
> 
> >>>>> On Mon, 02 Oct 2017 19:08:59 +0300, Eli Zaretskii <eliz@gnu.org> said:
> 
> > I think the second thread calls setjmp and clobbers the values set
> > by the main thread, when the main thread called setjmp.  We need to
> > eliminate this possibility of threads stepping on each other's toes.
> 
> Make the global variable `getcjmp' thread-local?

That indeed was the central part of the solution I installed.  But it
isn't enough, because in a TTY session C-g triggers a SIGINT, which is
delivered to the main thread.  So we need also to make sure that when
the signal handler calls quit_throw_to_read_char, current_thread
points to main_thread, we have the global lock held by the main
thread, and all our Lisp thread machinery is aware that it's the main
thread that's running.  Otherwise, we are asking for trouble.

Note that this means the effect of C-g while I/O APIs are called from
non-main threads is inherently unportable: the effect will be
different in TTY and GUI sessions on Unix, and also on Windows (where
there are no signals, and therefore the original recipe didn't crash
at all, but instead interrupted the sit-for on the non-main thread and
caused that thread's early demise).

After the change, sit-for on non-main thread is effectively a
sleep-for, at least on Unix TTY frames (and I think on GUI frames as
well).  But on MS-Windows and I think also NS it still works as
sit-for on the non-main thread.

Thanks.





  reply	other threads:[~2017-10-04  8:14 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
2017-10-09 11:01                                   ` Eli Zaretskii
2017-10-04  7:39               ` YAMAMOTO Mitsuharu
2017-10-04  8:14                 ` Eli Zaretskii [this message]
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=83bmlnz5wd.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=28630@debbugs.gnu.org \
    --cc=agrambot@gmail.com \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    --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.