From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.bugs Subject: bug#28630: 27.0.50; C-g while a non-main thread is sitting crashes Emacs Date: Wed, 04 Oct 2017 16:39:27 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <87efqri8x9.fsf@gmail.com> <874lrjy2rz.fsf@gmail.com> <831smm52v4.fsf@gnu.org> <87d166rb6n.fsf@gmail.com> <83o9pq3eix.fsf@gnu.org> <838tgt352c.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1507102818 28473 195.159.176.226 (4 Oct 2017 07:40:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Oct 2017 07:40:18 +0000 (UTC) User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?UTF-8?Q?Shij=C5=8D?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) Cc: 28630@debbugs.gnu.org, tom@tromey.com, agrambot@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 04 09:40:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzeHq-0006KL-J5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Oct 2017 09:40:10 +0200 Original-Received: from localhost ([::1]:33548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzeHv-0004GM-O5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Oct 2017 03:40:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzeHm-0004FU-AJ for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 03:40:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzeHi-0004fi-2e for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 03:40:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzeHh-0004f9-Vq for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 03:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dzeHh-0002GV-Lj for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2017 03:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: YAMAMOTO Mitsuharu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Oct 2017 07:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28630 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28630-submit@debbugs.gnu.org id=B28630.15071027728642 (code B ref 28630); Wed, 04 Oct 2017 07:40:01 +0000 Original-Received: (at 28630) by debbugs.gnu.org; 4 Oct 2017 07:39:32 +0000 Original-Received: from localhost ([127.0.0.1]:47393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzeHE-0002FK-2b for submit@debbugs.gnu.org; Wed, 04 Oct 2017 03:39:32 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:52715) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzeHC-0002F9-0R for 28630@debbugs.gnu.org; Wed, 04 Oct 2017 03:39:30 -0400 Original-Received: from fermat1.math.s.chiba-u.ac.jp (fermat [192.168.32.10]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 30B31F08F4; Wed, 4 Oct 2017 16:39:27 +0900 (JST) (envelope-from mituharu@math.s.chiba-u.ac.jp) In-Reply-To: <838tgt352c.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137873 Archived-At: >>>>> On Mon, 02 Oct 2017 19:08:59 +0300, Eli Zaretskii 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? YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp diff --git a/src/keyboard.c b/src/keyboard.c index e8701b8870..42d51a2ee8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -145,10 +145,6 @@ static Lisp_Object recover_top_level_message; /* Message normally displayed by Vtop_level. */ static Lisp_Object regular_top_level_message; -/* For longjmp to where kbd input is being done. */ - -static sys_jmp_buf getcjmp; - /* True while displaying for echoing. Delays C-g throwing. */ static bool echoing; @@ -3325,13 +3321,13 @@ record_char (Lisp_Object c) static void save_getcjmp (sys_jmp_buf temp) { - memcpy (temp, getcjmp, sizeof getcjmp); + memcpy (temp, current_thread->getcjmp, sizeof current_thread->getcjmp); } static void restore_getcjmp (sys_jmp_buf temp) { - memcpy (getcjmp, temp, sizeof getcjmp); + memcpy (current_thread->getcjmp, temp, sizeof current_thread->getcjmp); } /* Low level keyboard/mouse input. @@ -10534,7 +10530,7 @@ quit_throw_to_read_char (bool from_signal) do_switch_frame (make_lispy_switch_frame (internal_last_event_frame), 0, 0, Qnil); - sys_longjmp (getcjmp, 1); + sys_longjmp (current_thread->getcjmp, 1); } DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, diff --git a/src/lisp.h b/src/lisp.h index 680c25d4c4..ed2423596e 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1865,8 +1865,6 @@ verify (offsetof (struct Lisp_Sub_Char_Table, contents) == (offsetof (struct Lisp_Vector, contents) + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object))); -#include "thread.h" - /*********************************************************************** Symbols ***********************************************************************/ @@ -3096,6 +3094,8 @@ union specbinding } bt; }; +#include "thread.h" + /* These 3 are defined as macros in thread.h. */ /* extern union specbinding *specpdl; */ /* extern union specbinding *specpdl_ptr; */ diff --git a/src/thread.h b/src/thread.h index 7fce8674f0..125ca23b55 100644 --- a/src/thread.h +++ b/src/thread.h @@ -177,6 +177,9 @@ struct thread_state It must do so ASAP. */ int not_holding_lock; + /* For longjmp to where kbd input is being done. */ + sys_jmp_buf getcjmp; + /* Threads are kept on a linked list. */ struct thread_state *next_thread; };