From unknown Fri Aug 15 16:55:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24047: [PROPOSED PATCH] =?UTF-8?Q?=E2=80=98signal=E2=80=99?= no longer returns 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 To: 24047@debbugs.gnu.org Cc: Paul Eggert X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1469110873624 (code B ref -1); Thu, 21 Jul 2016 14:22:01 +0000 Received: (at submit) by debbugs.gnu.org; 21 Jul 2016 14:21:13 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 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 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 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 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 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) 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) 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 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) 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) From: Paul Eggert Date: Thu, 21 Jul 2016 16:20:27 +0200 Message-Id: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 From unknown Fri Aug 15 16:55:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24047: Should 'signal' sometimes return? References: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> In-Reply-To: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Jul 2016 12:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24047 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 24047@debbugs.gnu.org Received: via spool by 24047-submit@debbugs.gnu.org id=B24047.14691898486659 (code B ref 24047); Fri, 22 Jul 2016 12:18:02 +0000 Received: (at 24047) by debbugs.gnu.org; 22 Jul 2016 12:17:28 +0000 Received: from localhost ([127.0.0.1]:60863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQZOS-0001jJ-48 for submit@debbugs.gnu.org; Fri, 22 Jul 2016 08:17:28 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQZOQ-0001j6-7F for 24047@debbugs.gnu.org; Fri, 22 Jul 2016 08:17:27 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7095116125C for <24047@debbugs.gnu.org>; Fri, 22 Jul 2016 05:17:20 -0700 (PDT) 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 cpxqaq52pD7Y for <24047@debbugs.gnu.org>; Fri, 22 Jul 2016 05:17:18 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id DFADA16125D for <24047@debbugs.gnu.org>; Fri, 22 Jul 2016 05:17:18 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 pJD9ZfCwLwyG for <24047@debbugs.gnu.org>; Fri, 22 Jul 2016 05:17:18 -0700 (PDT) Received: from [192.168.1.52] (AMontpellier-656-1-366-38.w109-210.abo.wanadoo.fr [109.210.214.38]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1B68A16125C for <24047@debbugs.gnu.org>; Fri, 22 Jul 2016 05:17:14 -0700 (PDT) From: Paul Eggert Message-ID: Date: Fri, 22 Jul 2016 14:16:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7BB3CBF2FA6A2EC2E2C41235" X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) This is a multi-part message in MIME format. --------------7BB3CBF2FA6A2EC2E2C41235 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Attached is a more-conservative version of the patch, which keeps the debug-on-quit behavior when the user types C-g, so that 'signal' never returns but C-g might still "return". This is in response to Stefan's email at . --------------7BB3CBF2FA6A2EC2E2C41235 Content-Type: text/x-patch; name="0001-signal-no-longer-returns.patch" Content-Disposition: attachment; filename="0001-signal-no-longer-returns.patch" Content-Transfer-Encoding: quoted-printable >From 8ac14fbe08d5cb14495ed6f57498abad41913804 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 22 Jul 2016 12:31:07 +0200 Subject: [PATCH] =3D?UTF-8?q?=3DE2=3D80=3D98signal=3DE2=3D80=3D99=3D20no=3D= 20longer=3D20returns?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit 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 (signal_or_quit): New function, with most of the old contents of Fsignal. (quit): New function, which uses signal_or_quit and which might return. All keyboard-based callers of Fsignal (Qquit, Qnil) changed to use this new function instead. (Fsignal): Use signal_or_quit. Now _Noreturn. All callers changed. (xsignal): Move to lisp.h. * src/lisp.h (xsignal): Now an inline function, as it's now just an alias for Fsignal. --- src/bytecode.c | 2 +- src/charset.c | 6 +++--- src/coding.c | 6 +++--- src/eval.c | 37 ++++++++++++++++++++++++------------- src/fileio.c | 2 +- src/keyboard.c | 6 +++--- src/lisp.h | 7 ++++++- src/nsmenu.m | 2 +- src/term.c | 2 +- src/w32fns.c | 2 +- src/w32menu.c | 9 ++++----- src/xfns.c | 6 +++--- src/xmenu.c | 6 +++--- 13 files changed, 54 insertions(+), 39 deletions(-) diff --git a/src/bytecode.c b/src/bytecode.c index 05bc9fc..ee1b79f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -386,7 +386,7 @@ struct byte_stack Vquit_flag =3D Qnil; \ if (EQ (Vthrow_on_input, flag)) \ Fthrow (Vthrow_on_input, Qt); \ - Fsignal (Qquit, Qnil); \ + quit (); \ } \ else if (pending_signals) \ process_pending_signals (); \ 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..33b82f7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1431,6 +1431,7 @@ struct handler * } =20 =0C +static Lisp_Object signal_or_quit (Lisp_Object, Lisp_Object, bool); static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig= , Lisp_Object data); @@ -1444,7 +1445,7 @@ static bool maybe_call_debugger (Lisp_Object condit= ions, Lisp_Object sig, Fkill_emacs (Qnil); if (EQ (Vthrow_on_input, flag)) Fthrow (Vthrow_on_input, Qt); - Fsignal (Qquit, Qnil); + quit (); } =20 DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, @@ -1460,9 +1461,29 @@ static bool maybe_call_debugger (Lisp_Object condi= tions, 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) { + signal_or_quit (error_symbol, data, false); + eassume (false); +} + +/* Quit, in response to a keyboard quit request. */ +Lisp_Object +quit (void) +{ + return signal_or_quit (Qquit, Qnil, true); +} + +/* Signal an error, or quit. ERROR_SYMBOL and DATA are as with Fsignal. + If KEYBOARD_QUIT, this is a quit; ERROR_SYMBOL should be + Qquit and DATA should be Qnil, and this function may return. + Otherwise this function is like Fsignal and does not return. */ + +static Lisp_Object +signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboar= d_quit) +{ /* When memory is full, ERROR-SYMBOL is nil, and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). That is a special case--don't do this in other situations. */ @@ -1542,7 +1563,7 @@ static bool maybe_call_debugger (Lisp_Object condit= ions, Lisp_Object sig, =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)) + if (keyboard_quit && debugger_called && EQ (real_error_symbol, Qqu= it)) return Qnil; } =20 @@ -1569,16 +1590,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 diff --git a/src/fileio.c b/src/fileio.c index b1f9d3c..66ea761 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4513,7 +4513,7 @@ buffer contents (in the accessible portion) with th= e file contents. PT - BEG, Z - PT - inserted); =20 if (read_quit) - Fsignal (Qquit, Qnil); + quit (); =20 /* Retval needs to be dealt with in all cases consistently. */ if (NILP (val)) diff --git a/src/keyboard.c b/src/keyboard.c index 8901ff0..ed49684 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -696,7 +696,7 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, in= t, Lisp_Object, =20 val =3D command_loop (); if (EQ (val, Qt)) - Fsignal (Qquit, Qnil); + quit (); /* Handle throw from read_minibuf when using minibuffer while it's active but we're in another window. */ if (STRINGP (val)) @@ -7581,7 +7581,7 @@ struct user_signal_info /* If we got a quit from within the menu computation, quit all the way out of it. This takes care of C-] in the debugger= . */ if (CONSP (arg) && EQ (XCAR (arg), Qquit)) - Fsignal (Qquit, Qnil); + quit (); =20 return Qnil; } @@ -10407,7 +10407,7 @@ shows the events before all translations (except = for input methods). immediate_quit =3D false; pthread_sigmask (SIG_SETMASK, &empty_mask, 0); saved =3D gl_state; - Fsignal (Qquit, Qnil); + quit (); gl_state =3D saved; } else diff --git a/src/lisp.h b/src/lisp.h index 39877d7..089f397 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3879,7 +3879,12 @@ 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); +extern Lisp_Object quit (void); +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); diff --git a/src/nsmenu.m b/src/nsmenu.m index 83ded6d..d1f4b02 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1843,7 +1843,7 @@ - (Lisp_Object)runDialogAt: (NSPoint)p =20 if (EQ (ret, Qundefined) && window_closed) /* Make close button pressed equivalent to C-g. */ - Fsignal (Qquit, Qnil); + quit (); =20 return ret; } diff --git a/src/term.c b/src/term.c index 81908b3..d54ff11 100644 --- a/src/term.c +++ b/src/term.c @@ -3759,7 +3759,7 @@ struct tty_menu_state /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means the menu was invoked with a mouse event as POSITION). */ if (!(menuflags & MENU_FOR_CLICK)) - Fsignal (Qquit, Qnil); + quit (); break; } =20 diff --git a/src/w32fns.c b/src/w32fns.c index d6b54d1..584e311 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -7584,7 +7584,7 @@ with offset DY added (default is -10). =20 /* Make "Cancel" equivalent to C-g. */ if (NILP (filename)) - Fsignal (Qquit, Qnil); + quit (); =20 return filename; } diff --git a/src/w32menu.c b/src/w32menu.c index 13296d9..7c66360 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -827,7 +827,7 @@ typedef int (WINAPI * MessageBoxW_Proc) ( { unblock_input (); /* Make "Cancel" equivalent to C-g. */ - Fsignal (Qquit, Qnil); + quit (); } =20 unblock_input (); @@ -1019,7 +1019,7 @@ typedef int (WINAPI * MessageBoxW_Proc) ( } else /* Make "Cancel" equivalent to C-g. */ - Fsignal (Qquit, Qnil); + quit (); =20 return Qnil; } @@ -1155,7 +1155,7 @@ typedef int (WINAPI * MessageBoxW_Proc) ( else if (answer =3D=3D IDNO) lispy_answer =3D build_string ("No"); else - Fsignal (Qquit, Qnil); + quit (); =20 for (temp =3D XCDR (contents); CONSP (temp); temp =3D XCDR (temp)) { @@ -1177,8 +1177,7 @@ typedef int (WINAPI * MessageBoxW_Proc) ( return value; } } - Fsignal (Qquit, Qnil); - return Qnil; + return quit (); } #endif /* !HAVE_DIALOGS */ =0C diff --git a/src/xfns.c b/src/xfns.c index 798dc49..c44997b 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6346,7 +6346,7 @@ with offset DY added (default is -10). =20 /* Make "Cancel" equivalent to C-g. */ if (NILP (file)) - Fsignal (Qquit, Qnil); + quit (); =20 decoded_file =3D DECODE_FILE (file); =20 @@ -6418,7 +6418,7 @@ with offset DY added (default is -10). =20 /* Make "Cancel" equivalent to C-g. */ if (NILP (file)) - Fsignal (Qquit, Qnil); + quit (); =20 decoded_file =3D DECODE_FILE (file); =20 @@ -6469,7 +6469,7 @@ Return either a font spec (for GTK versions >=3D 3.= 2) or a string unblock_input (); =20 if (NILP (font)) - Fsignal (Qquit, Qnil); + quit (); =20 return unbind_to (count, font); } diff --git a/src/xmenu.c b/src/xmenu.c index 9e1a817..9ab7bdf 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1649,7 +1649,7 @@ struct next_popup_x_y { unblock_input (); /* Make "Cancel" equivalent to C-g. */ - Fsignal (Qquit, Qnil); + quit (); } =20 unblock_input (); @@ -1913,7 +1913,7 @@ struct next_popup_x_y } else /* Make "Cancel" equivalent to C-g. */ - Fsignal (Qquit, Qnil); + quit (); =20 return Qnil; } @@ -2304,7 +2304,7 @@ struct next_popup_x_y if (!(menuflags & MENU_FOR_CLICK)) { unblock_input (); - Fsignal (Qquit, Qnil); + quit (); } break; } --=20 1.7.9.5 --------------7BB3CBF2FA6A2EC2E2C41235-- From unknown Fri Aug 15 16:55:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24047: Should 'signal' sometimes return? Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jul 2016 18:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24047 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 24047@debbugs.gnu.org Received: via spool by 24047-submit@debbugs.gnu.org id=B24047.146929906723785 (code B ref 24047); Sat, 23 Jul 2016 18:38:02 +0000 Received: (at 24047) by debbugs.gnu.org; 23 Jul 2016 18:37:47 +0000 Received: from localhost ([127.0.0.1]:35152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bR1o2-0006BY-RC for submit@debbugs.gnu.org; Sat, 23 Jul 2016 14:37:46 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:50512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bR1o0-0006BL-SX for 24047@debbugs.gnu.org; Sat, 23 Jul 2016 14:37:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BNFgA731xV/6SNCkxcDoMCVF6CUIVVvHUbCoVxBAICgTw8EQEBAQEBAQGBCkEFg10BAQECAQECUyMFCws0EhQUBA0kiDcIDc8WAQEBAQYCAR+LOoQiEQFRB4QtBZchhBqEGpNqgUUjgzpaIjEBgQuBOwEBAQ X-IPAS-Result: A0BNFgA731xV/6SNCkxcDoMCVF6CUIVVvHUbCoVxBAICgTw8EQEBAQEBAQGBCkEFg10BAQECAQECUyMFCws0EhQUBA0kiDcIDc8WAQEBAQYCAR+LOoQiEQFRB4QtBZchhBqEGpNqgUUjgzpaIjEBgQuBOwEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="249039968" Received: from 76-10-141-164.dsl.teksavvy.com (HELO pastel.home) ([76.10.141.164]) by ironport2-out.teksavvy.com with ESMTP; 23 Jul 2016 14:37:37 -0400 Received: by pastel.home (Postfix, from userid 20848) id 4D9F564D20; Sat, 23 Jul 2016 14:37:36 -0400 (EDT) From: Stefan Monnier Message-ID: References: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> Date: Sat, 23 Jul 2016 14:37:36 -0400 In-Reply-To: (Paul Eggert's message of "Fri, 22 Jul 2016 14:16:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Attached is a more-conservative version of the patch, which keeps the > debug-on-quit behavior when the user types C-g, so that 'signal' never > returns but C-g might still "return". This is in response to Stefan's email > at . Haven't looked in detail, but it looks OK. A further patch could change the new `quit' function so it checks debug-on-quit, and either calls the debugger or calls Fsignal. This way we don't need the intermediate signal_or_quit function. Stefan From unknown Fri Aug 15 16:55:19 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#24047: closed (Re: bug#24047: Should 'signal' sometimes return?) Message-ID: References: <2045088a-40b7-2778-ae19-f3df3b2b678b@cs.ucla.edu> <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> X-Gnu-PR-Message: they-closed 24047 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 24047@debbugs.gnu.org Date: Sun, 24 Jul 2016 22:43:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1469400182-2688-1" This is a multi-part message in MIME format... ------------=_1469400182-2688-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #24047: [PROPOSED PATCH] =E2=80=98signal=E2=80=99 no longer returns which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 24047@debbugs.gnu.org. --=20 24047: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24047 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1469400182-2688-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 24047-done) by debbugs.gnu.org; 24 Jul 2016 22:42:45 +0000 Received: from localhost ([127.0.0.1]:36092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRS6f-0000gs-1r for submit@debbugs.gnu.org; Sun, 24 Jul 2016 18:42:45 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRS6c-0000ge-RL for 24047-done@debbugs.gnu.org; Sun, 24 Jul 2016 18:42:43 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D65AA160972; Sun, 24 Jul 2016 15:42:36 -0700 (PDT) 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 iNySgNw6F_fY; Sun, 24 Jul 2016 15:42:35 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E160A160F53; Sun, 24 Jul 2016 15:42:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu 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 IyRd45SX6bLx; Sun, 24 Jul 2016 15:42:35 -0700 (PDT) Received: from [192.168.48.69] (unknown [46.218.124.202]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2F2A6160972; Sun, 24 Jul 2016 15:42:35 -0700 (PDT) Subject: Re: bug#24047: Should 'signal' sometimes return? To: Stefan Monnier References: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> From: Paul Eggert Message-ID: <2045088a-40b7-2778-ae19-f3df3b2b678b@cs.ucla.edu> Date: Mon, 25 Jul 2016 00:42:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------46669B357F15ABD6F14A9C6D" X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 24047-done Cc: 24047-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) This is a multi-part message in MIME format. --------------46669B357F15ABD6F14A9C6D Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 07/23/2016 08:37 PM, Stefan Monnier wrote: > Haven't looked in detail, but it looks OK. Thanks, I installed it in 'master' and am marking this as done. > > A further patch could change the new `quit' function so it checks > debug-on-quit, and either calls the debugger or calls Fsignal. This way > we don't need the intermediate signal_or_quit function. I tried something along those lines (see attached), but wasn't convinced that the result was correct (there are a lot of flags flying around), and my patch would cause quits to traverse the handler list twice, which seems inelegant. --------------46669B357F15ABD6F14A9C6D Content-Type: text/x-patch; name="attempt.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="attempt.diff" diff --git a/src/eval.c b/src/eval.c index 33b82f7..74e1409 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1431,10 +1431,9 @@ struct handler * } -static Lisp_Object signal_or_quit (Lisp_Object, Lisp_Object, bool); -static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); -static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, - Lisp_Object data); +static struct handler const return_nil_handler = { 0, }; +static struct handler *find_condition_handler (Lisp_Object, Lisp_Object, + Lisp_Object); void process_quit_flag (void) @@ -1465,25 +1464,6 @@ static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, attributes: noreturn) (Lisp_Object error_symbol, Lisp_Object data) { - signal_or_quit (error_symbol, data, false); - eassume (false); -} - -/* Quit, in response to a keyboard quit request. */ -Lisp_Object -quit (void) -{ - return signal_or_quit (Qquit, Qnil, true); -} - -/* Signal an error, or quit. ERROR_SYMBOL and DATA are as with Fsignal. - If KEYBOARD_QUIT, this is a quit; ERROR_SYMBOL should be - Qquit and DATA should be Qnil, and this function may return. - Otherwise this function is like Fsignal and does not return. */ - -static Lisp_Object -signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) -{ /* When memory is full, ERROR-SYMBOL is nil, and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). That is a special case--don't do this in other situations. */ @@ -1491,8 +1471,6 @@ static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object string; Lisp_Object real_error_symbol = (NILP (error_symbol) ? Fcar (data) : error_symbol); - register Lisp_Object clause = Qnil; - struct handler *h; immediate_quit = 0; abort_on_gc = 0; @@ -1537,37 +1515,8 @@ static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Vsignaling_function = backtrace_function (pdl); } - for (h = handlerlist; h; h = h->next) - { - if (h->type != CONDITION_CASE) - continue; - clause = find_handler_clause (h->tag_or_ch, conditions); - if (!NILP (clause)) - break; - } - - if (/* Don't run the debugger for a memory-full error. - (There is no room in memory to do that!) */ - !NILP (error_symbol) - && (!NILP (Vdebug_on_signal) - /* If no handler is present now, try to run the debugger. */ - || NILP (clause) - /* A `debug' symbol in the handler list disables the normal - suppression of the debugger. */ - || (CONSP (clause) && !NILP (Fmemq (Qdebug, clause))) - /* Special handler that means "print a message and run debugger - if requested". */ - || EQ (h->tag_or_ch, Qerror))) - { - bool debugger_called - = 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 (keyboard_quit && debugger_called && EQ (real_error_symbol, Qquit)) - return Qnil; - } - - if (!NILP (clause)) + struct handler *h = find_condition_handler (conditions, error_symbol, data); + if (h) { Lisp_Object unwind_data = (NILP (error_symbol) ? data : Fcons (error_symbol, data)); @@ -1762,6 +1711,57 @@ static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, return Qnil; } +struct handler * +find_condition_handler (Lisp_Object conditions, Lisp_Object error_symbol, + Lisp_Object data) +{ + Lisp_Object clause = Qnil; + struct handler *h; + + for (h = handlerlist; h; h = h->next) + { + if (h->type != CONDITION_CASE) + continue; + clause = find_handler_clause (h->tag_or_ch, conditions); + if (!NILP (clause)) + break; + } + + if (/* Don't run the debugger for a memory-full error. + (There is no room in memory to do that!) */ + !NILP (error_symbol) + && (!NILP (Vdebug_on_signal) + /* If no handler is present now, try to run the debugger. */ + || NILP (clause) + /* A `debug' symbol in the handler list disables the normal + suppression of the debugger. */ + || (CONSP (clause) && !NILP (Fmemq (Qdebug, clause))) + /* Special handler that means "print a message and run debugger + if requested". */ + || EQ (h->tag_or_ch, Qerror))) + { + /* We can't return values to code which signaled an error, but we + can continue code which has signaled a quit. */ + if (maybe_call_debugger (conditions, error_symbol, data) + && EQ (NILP (error_symbol) ? Fcar (data) : error_symbol, Qquit)) + return (struct handler *) &return_nil_handler; + } + + return h; +} + +/* Quit, in response to a keyboard quit request. + Normally this is like (signal 'quit nil) and does not return. + However, the debugger can cause this to return. */ + +Lisp_Object +quit (void) +{ + AUTO_LIST1 (conditions, Qquit); + if (find_condition_handler (conditions, Qquit, Qnil) != &return_nil_handler) + Fsignal (Qquit, Qnil); + return Qnil; +} /* Format and return a string; called like vprintf. */ Lisp_Object --------------46669B357F15ABD6F14A9C6D-- ------------=_1469400182-2688-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 21 Jul 2016 14:21:13 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 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 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 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 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 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) 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) 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 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) 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) From: Paul Eggert To: bug-gnu-emacs@gnu.org Subject: [PROPOSED PATCH] =?UTF-8?q?=E2=80=98signal=E2=80=99=20no=20longer=20?= =?UTF-8?q?returns?= Date: Thu, 21 Jul 2016 16:20:27 +0200 Message-Id: <1469110827-9827-1-git-send-email-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 ------------=_1469400182-2688-1--