From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#24047: [PROPOSED PATCH] =?UTF-8?Q?=E2=80=98signal=E2=80=99?= no longer returns Date: Thu, 21 Jul 2016 16:20:27 +0200 Message-ID: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1469110948 6907 80.91.229.3 (21 Jul 2016 14:22:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Jul 2016 14:22:28 +0000 (UTC) Cc: Paul Eggert To: 24047@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 21 16:22:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bQEre-0003kv-Lu for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jul 2016 16:22:14 +0200 Original-Received: from localhost ([::1]:41114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQEre-0005AL-0K for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jul 2016 10:22:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQErW-00058U-5k for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:22:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQErR-00019t-Vj for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:22:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQErR-00019o-Sf for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:22:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bQErR-0000BB-LH for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Jul 2016 14:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24047 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1469110873624 (code B ref -1); Thu, 21 Jul 2016 14:22:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jul 2016 14:21:13 +0000 Original-Received: from localhost ([127.0.0.1]:60533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQEqa-00009o-Ds for submit@debbugs.gnu.org; Thu, 21 Jul 2016 10:21:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQEqT-00008t-Tj for submit@debbugs.gnu.org; Thu, 21 Jul 2016 10:21:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQEqJ-000100-PV for submit@debbugs.gnu.org; Thu, 21 Jul 2016 10:20:56 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:32862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQEqJ-0000zv-Mh for submit@debbugs.gnu.org; Thu, 21 Jul 2016 10:20:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQEqD-0004vZ-T6 for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:20:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQEq8-0000yz-9D for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:20:44 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:42473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQEq7-0000yn-VR for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2016 10:20:40 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2D1251611E6 for ; Thu, 21 Jul 2016 07:20:39 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id v0vjMCImiYdQ; Thu, 21 Jul 2016 07:20:38 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2C67B1611DF; Thu, 21 Jul 2016 07:20:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WM463qtgwkj9; Thu, 21 Jul 2016 07:20:38 -0700 (PDT) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 06DBE16119A; Thu, 21 Jul 2016 07:20:38 -0700 (PDT) X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:121381 Archived-At: Although for decades =E2=80=98signal=E2=80=99 has been documented to not = return, a corner case in the Lisp debugger causes =E2=80=98signal=E2=80=99 to ret= urn. Remove the corner case and adjust Emacs internals accordingly. An alternative would be to document the corner case, but this would complicate the Lisp API unnecessarily. * src/eval.c (maybe_call_debugger): Now returns void, not bool. Caller changed. (Fsignal): Now _Noreturn. Callers adjusted accordingly. (xsignal): Move to lisp.h. * src/lisp.h (process_quit_flag): Now _Noreturn. (xsignal): Now an inline function, as it's now simply an alias for Fsignal. --- src/charset.c | 6 +++--- src/coding.c | 6 +++--- src/eval.c | 33 ++++++--------------------------- src/keyboard.c | 4 ---- src/lisp.h | 8 ++++++-- 5 files changed, 18 insertions(+), 39 deletions(-) diff --git a/src/charset.c b/src/charset.c index 95a9c57..05469aa 100644 --- a/src/charset.c +++ b/src/charset.c @@ -843,9 +843,9 @@ range of code points (in CHARSET) of target character= s. */) int nchars; =20 if (nargs !=3D charset_arg_max) - return Fsignal (Qwrong_number_of_arguments, - Fcons (intern ("define-charset-internal"), - make_number (nargs))); + Fsignal (Qwrong_number_of_arguments, + Fcons (intern ("define-charset-internal"), + make_number (nargs))); =20 attrs =3D Fmake_vector (make_number (charset_attr_max), Qnil); =20 diff --git a/src/coding.c b/src/coding.c index 29c90f0..a8ddc81 100644 --- a/src/coding.c +++ b/src/coding.c @@ -10546,9 +10546,9 @@ assigned to each coding category (see `coding-cat= egory-list'). return Qnil; =20 short_args: - return Fsignal (Qwrong_number_of_arguments, - Fcons (intern ("define-coding-system-internal"), - make_number (nargs))); + Fsignal (Qwrong_number_of_arguments, + Fcons (intern ("define-coding-system-internal"), + make_number (nargs))); } =20 =20 diff --git a/src/eval.c b/src/eval.c index 72facd5..a850446 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1432,7 +1432,7 @@ struct handler * =20 =0C static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); -static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig= , +static void maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig= , Lisp_Object data); =20 void @@ -1460,7 +1460,8 @@ static bool maybe_call_debugger (Lisp_Object condit= ions, Lisp_Object sig, See Info anchor `(elisp)Definition of signal' for some details on how th= is error message is constructed. If the signal is handled, DATA is made available to the handler. -See also the function `condition-case'. */) +See also the function `condition-case'. */ + attributes: noreturn) (Lisp_Object error_symbol, Lisp_Object data) { /* When memory is full, ERROR-SYMBOL is nil, @@ -1537,14 +1538,7 @@ static bool maybe_call_debugger (Lisp_Object condi= tions, Lisp_Object sig, /* Special handler that means "print a message and run debugger if requested". */ || EQ (h->tag_or_ch, Qerror))) - { - bool debugger_called - =3D maybe_call_debugger (conditions, error_symbol, data); - /* We can't return values to code which signaled an error, but we - can continue code which has signaled a quit. */ - if (debugger_called && EQ (real_error_symbol, Qquit)) - return Qnil; - } + maybe_call_debugger (conditions, error_symbol, data); =20 if (!NILP (clause)) { @@ -1569,16 +1563,6 @@ static bool maybe_call_debugger (Lisp_Object condi= tions, Lisp_Object sig, fatal ("%s", SDATA (string)); } =20 -/* Internal version of Fsignal that never returns. - Used for anything but Qquit (which can return from Fsignal). */ - -void -xsignal (Lisp_Object error_symbol, Lisp_Object data) -{ - Fsignal (error_symbol, data); - emacs_abort (); -} - /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ =20 void @@ -1700,7 +1684,7 @@ static bool maybe_call_debugger (Lisp_Object condit= ions, Lisp_Object sig, =3D SIG is the error symbol, and DATA is the rest of the data. =3D SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). This is for memory-full errors only. */ -static bool +static void maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Objec= t data) { Lisp_Object combined_data; @@ -1719,12 +1703,7 @@ static bool maybe_call_debugger (Lisp_Object condi= tions, Lisp_Object sig, && ! skip_debugger (conditions, combined_data) /* RMS: What's this for? */ && when_entered_debugger < num_nonmacro_input_events) - { - call_debugger (list2 (Qerror, combined_data)); - return 1; - } - - return 0; + call_debugger (list2 (Qerror, combined_data)); } =20 static Lisp_Object diff --git a/src/keyboard.c b/src/keyboard.c index 8901ff0..6b5528d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10402,13 +10402,9 @@ shows the events before all translations (except= for input methods). then quit right away. */ if (immediate_quit && NILP (Vinhibit_quit)) { - struct gl_state_s saved; - immediate_quit =3D false; pthread_sigmask (SIG_SETMASK, &empty_mask, 0); - saved =3D gl_state; Fsignal (Qquit, Qnil); - gl_state =3D saved; } else { /* Else request quit when it's safe. */ diff --git a/src/lisp.h b/src/lisp.h index 39877d7..50ee8ea 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3230,7 +3230,7 @@ struct handler extern void process_pending_signals (void); extern bool volatile pending_signals; =20 -extern void process_quit_flag (void); +extern _Noreturn void process_quit_flag (void); #define QUIT \ do { \ if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ @@ -3879,7 +3879,11 @@ extern void map_obarray (Lisp_Object, void (*) (Li= sp_Object, Lisp_Object), extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *arg= s, Lisp_Object (*funcall) (ptrdiff_t nargs, Lisp_Object *args)); -extern _Noreturn void xsignal (Lisp_Object, Lisp_Object); +INLINE _Noreturn void +xsignal (Lisp_Object error_symbol, Lisp_Object data) +{ + Fsignal (error_symbol, data); +} extern _Noreturn void xsignal0 (Lisp_Object); extern _Noreturn void xsignal1 (Lisp_Object, Lisp_Object); extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object); --=20 1.7.9.5