From unknown Tue Jun 17 20:18:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#5662 <5662@debbugs.gnu.org> To: bug#5662 <5662@debbugs.gnu.org> Subject: Status: flet not undone on lisp nesting error Reply-To: bug#5662 <5662@debbugs.gnu.org> Date: Wed, 18 Jun 2025 03:18:14 +0000 retitle 5662 flet not undone on lisp nesting error reassign 5662 emacs submitter 5662 Dan Davison severity 5662 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 28 21:33:12 2010 Received: (at submit) by debbugs.gnu.org; 1 Mar 2010 02:33:12 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NlvRY-0002vg-0j for submit@debbugs.gnu.org; Sun, 28 Feb 2010 21:33:12 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NlvPb-0002tz-1b for submit@debbugs.gnu.org; Sun, 28 Feb 2010 21:31:13 -0500 Received: from mail.gnu.org ([199.232.76.166]:45954 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NlvPV-0005jS-V6 for submit@debbugs.gnu.org; Sun, 28 Feb 2010 21:31:07 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NlvPO-0006wG-J1 for submit@debbugs.gnu.org; Sun, 28 Feb 2010 21:31:02 -0500 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on monty-python X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,UNPARSEABLE_RELAY autolearn=ham version=3.1.0 Received: from lists.gnu.org ([199.232.76.165]:42106) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NlvPO-0006vl-Cm for submit@debbugs.gnu.org; Sun, 28 Feb 2010 21:30:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NlvPN-0005Ih-M5 for bug-gnu-emacs@gnu.org; Sun, 28 Feb 2010 21:30:57 -0500 Received: from [140.186.70.92] (port=37827 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NlvPL-0005IB-RV for bug-gnu-emacs@gnu.org; Sun, 28 Feb 2010 21:30:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NlvPJ-0001Ls-Li for bug-gnu-emacs@gnu.org; Sun, 28 Feb 2010 21:30:55 -0500 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:63234) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NlvPJ-0001Ln-Ca for bug-gnu-emacs@gnu.org; Sun, 28 Feb 2010 21:30:53 -0500 Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o212Up3b013181 for ; Mon, 1 Mar 2010 02:30:51 GMT Received: by blackcap.stats.ox.ac.uk (Postfix, from userid 5158) id D31463201D; Mon, 1 Mar 2010 02:30:51 +0000 (GMT) From: Dan Davison To: bug-gnu-emacs@gnu.org Subject: flet not undone on lisp nesting error Date: Sun, 28 Feb 2010 21:30:49 -0500 Message-ID: <87fx4k4vty.fsf@stats.ox.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Solaris 8 (1) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 28 Feb 2010 21:33:10 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) If I trigger a lisp nesting error with an infinite recursion inside a let and an flet binding, then the effects of the flet are not undone, resulting in a change of binding at the top-level. (defun g () 'g-orig) (setq a 'a-orig) (defun h () (let ((a 'a-new)) (flet ((g () 'g-new)) (h)))) (h) ;; <-- Lisp nesting exceeds `max-lisp-eval-depth' (g) ;; g-new ! a ;; a-orig Dan If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. If you would like to further debug the crash, please read the file /usr/share/emacs/23.1/etc/DEBUG for instructions. In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.3) of 2009-11-10 on vernadsky, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.10604000 configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_GB.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default-enable-multibyte-characters: t Major mode: Article Minor modes in effect: erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-track-minor-mode: t erc-match-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-netsplit-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t show-paren-mode: t recentf-mode: t yas/minor-mode: t diff-auto-refine-mode: t shell-dirtrack-mode: t tooltip-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-x C-s M-g 1 0 0 SPC SPC q 2 0 0 C-s f l e t C-s C-s C-SPC M-> M-w M-x r e p o r t b u Recent messages: End of message nnimap: Setting marks in INBOX...done No more unread newsgroups Retrieving newsgroup: INBOX... nnimap: Updating info for INBOX...done Fetching headers for INBOX...done Generating summary...done Mark saved where search started Mark set Saved text from "If I trigger a lisp nesting error with a" From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 05 15:30:52 2010 Received: (at 5662) by debbugs.gnu.org; 5 Mar 2010 20:30:52 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NneAd-0006wD-Vw for submit@debbugs.gnu.org; Fri, 05 Mar 2010 15:30:52 -0500 Received: from tomts13.bellnexxia.net ([209.226.175.34] helo=tomts13-srv.bellnexxia.net) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NneAc-0006w6-RW for 5662@debbugs.gnu.org; Fri, 05 Mar 2010 15:30:51 -0500 Received: from toip5.srvr.bell.ca ([209.226.175.88]) by tomts13-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20100305203045.RDKA20196.tomts13-srv.bellnexxia.net@toip5.srvr.bell.ca> for <5662@debbugs.gnu.org>; Fri, 5 Mar 2010 15:30:45 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAHnzkEtGN5E3/2dsb2JhbACbSHS3N4R3BIMXiyM Received: from bas1-montreal42-1178046775.dsl.bell.ca (HELO ceviche.home) ([70.55.145.55]) by toip5.srvr.bell.ca with ESMTP; 05 Mar 2010 15:30:03 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 667F9B44D4; Fri, 5 Mar 2010 15:30:45 -0500 (EST) From: Stefan Monnier To: Dan Davison Subject: Re: bug#5662: flet not undone on lisp nesting error Message-ID: References: <87fx4k4vty.fsf@stats.ox.ac.uk> Date: Fri, 05 Mar 2010 15:30:45 -0500 In-Reply-To: <87fx4k4vty.fsf@stats.ox.ac.uk> (Dan Davison's message of "Sun, 28 Feb 2010 21:30:49 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 5662 Cc: 5662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.2 (--) > If I trigger a lisp nesting error with an infinite recursion inside a > let and an flet binding, then the effects of the flet are not undone, > resulting in a change of binding at the top-level. > (defun g () 'g-orig) > (setq a 'a-orig) > (defun h () > (let ((a 'a-new)) > (flet ((g () 'g-new)) > (h)))) > (h) ;; <-- Lisp nesting exceeds `max-lisp-eval-depth' > (g) ;; g-new ! > a ;; a-orig I can indeed reproduce it. I'm not sure yet what's going on, but it might be due to the "Lisp nesting exceeds `max-lisp-eval-depth'" error happening in the unwind-protect code (i.e. while undoing the `g' binding). The explanation can't be quite so simple, but my gut feeling tells me it's got to do with it. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 10 22:07:14 2014 Received: (at 5662) by debbugs.gnu.org; 11 Nov 2014 03:07:14 +0000 Received: from localhost ([127.0.0.1]:56757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xo1nV-0008OE-77 for submit@debbugs.gnu.org; Mon, 10 Nov 2014 22:07:13 -0500 Received: from nm8-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.95]:50123) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xo10o-0007Cp-G9 for 5662@debbugs.gnu.org; Mon, 10 Nov 2014 21:16:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1415672214; bh=1mR/E07eUifQmUHEcM7g9OhdBed2DEYaWF99oal5SxY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From:Subject; b=X0GLcoOO0WPTHyaMHrWxs/HNbYQS7UYQW0sYOuDx3n7jMfHrkOcDcP7zVfirQNy1ohnmblv4HKbz6JsGVLqm1i7d75358l5GVxcmYNjnq7vfQvloMS5Q/JeN8TzkrwNHsD+6kWGvJgYpEV0YdWU+rmqbwZQjJ56t+wKkEvaWFm49Fn/UsCoewlRaxN7FsNSZN8yWVFirxJqmVlzk1rVb8opHQyBGnhZDZuCWzVU6c7ivQ4M3hHWzuK7ZQSVAWlgsFNATDzksmBbDveZg/sGwV/QReMZ+IRG3kZP8dv505CpsqGTdCr22HANJiRiFTsqcE3l/5B0HZ5sDsGFa863EOA== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.com; b=oP74x58fzKmlcMRD4zOaUPn63kJPCgQ1VGSwu+Ji2YNyRfkUnLE18QMGTx+MSCCdVDs/MZoT+A8swU9JkCHmW5DH09JMDz1hJ7tNVUXkUeCgbAd1coC9BHj31ZpJ5kU8g3exKpbzQf4FMlfc2Xzv8WE5IS0gBNQey8ZUTnqJ3IHjzIjUc5N1QSNE7wJ1YaDtETFgKEVNVe1yyio+kDs8DFVMjYApq7M+BDZKgCA/vZrXZfhvOgbWnzvxkd2kn52UkDOI610DAebmY1TSiquhOnQ+xDDuj9ACwBqXNMinHTy+stYtcaDthEUHfR86oDgZdFH3cfLeBATwXYvw86Q0IQ==; Received: from [98.139.212.153] by nm8.bullet.mail.bf1.yahoo.com with NNFMP; 11 Nov 2014 02:16:54 -0000 Received: from [98.139.211.202] by tm10.bullet.mail.bf1.yahoo.com with NNFMP; 11 Nov 2014 02:16:54 -0000 Received: from [127.0.0.1] by smtp211.mail.bf1.yahoo.com with NNFMP; 11 Nov 2014 02:16:54 -0000 X-Yahoo-Newman-Id: 103210.99389.bm@smtp211.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: KTQzTKgVM1noe8Hbhyuv4ZbmGTLzMmzevMC6SSvNTk8opA6 HowKR_OopAx98JSxmJHKMre3BqXUusu_9BPs7eCWzso3M4cqIzCLHnV8t5E4 Q4w2CQB2RLygQ92FKYP_Z_kw9bEnvOtjQLpJTRe0ic6ZVFfwVoY6Tx8ZkE7J le5wG4mEVBFEOd4eBFMDHGgALGX23S2DBrX3MgcQoqUuMsPksSDyWWxA4Pln 2cLk0WHnjRpuxNkUwX36kyDjJXWVpyZ6u70a1OOyRHBSeD68E3WuVnBUsGGI Sc3dMxQLgz9tZiV1zxiSrcmfLhOOUO7qbNQucY6WHkdybYiPUKICwQoy5RKL 8sJDxdBtE7oEIVEUlpkVYRQzqimizJXH2knxqBMuXcaeyVdd_Bd0Scs5x6Zj ddon3U3Am9hiaYj6ZaBHswgjIFQGVR6Rw7yc2cahCfbNDHBT7xgYnGSCsCjN g3u.BP7uZQ9wGeZ09Y4yuKqQ4bsM951GKqy9ePEdBnx1suq1QHggztTIt0eK KU71HLIlhHgxFVOnHyBXrksLbdWbe7PI- X-Yahoo-SMTP: jby.eyiswBD6LY3ZTR_MrLahcaAWtxA- Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: bug#5662: flet not undone on lisp nesting error From: Jinseop Kim In-Reply-To: Date: Tue, 11 Nov 2014 11:16:48 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: References: <87fx4k4vty.fsf@stats.ox.ac.uk> To: 5662@debbugs.gnu.org X-Mailer: Apple Mail (2.1990.1) X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 5662 X-Mailman-Approved-At: Mon, 10 Nov 2014 22:07:12 -0500 Cc: Dan Davison , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.5 (/) You can see the bug of 'unwind-protect' using the following code. We must see the message =E2=80=9Cfinally=E2=80=9D, but are not output. ```elisp (defun endless-recursive () (endless-recursive)) (unwind-protect (endless-recursive) ;; body (message "finally=E2=80=9D)) ;; unwind-forms ``` The `unwind-protect=E2=80=99 will call the `eval_sub=E2=80=99 function. And, the `eval_sub=E2=80=99 function check whether the infinite = recursion as following code. ```c /* ./src/eval.c:2086: */ if (++lisp_eval_depth > max_lisp_eval_depth) { if (max_lisp_eval_depth < 100) max_lisp_eval_depth =3D 100; if (lisp_eval_depth > max_lisp_eval_depth) error ("Lisp nesting exceeds `max-lisp-eval-depth'"); } ``` The cause of problem is that `unwind-forms=E2=80=99 will call the = `eval_sub=E2=80=99 function. Of course, the `eval_sub=E2=80=99 function check for infinite recursion. Consequently, the `unwind-protect=E2=80=99 wouldn't evaluate. You must be noted step 7~10. Problem's steps: 1. eval.c:1208:Funwind_protect: record_unwind_protect (unwind_body, = XCDR (args));=20 2. eval.c:1209:Funwind_protect: val =3D eval_sub (XCAR (args));=20 3. eval.c:2090:eval_sub: if (lisp_eval_depth > max_lisp_eval_depth) = error ("Lisp nesting exceeds `max-lisp-eval-depth'=E2=80=9D);=20 4. eval.c:1582:xsignal: Fsignal (error_symbol, data);=20 5. eval.c:1558:Fsignal: unwind_to_catch (h, unwind_data);=20 6. eval.c:1161:unwind_to_catch: unbind_to (handlerlist->pdlcount, = Qnil);=20 7. eval.c:3305:unbind_to: unwind_body // specpdl_ptr->unwind_ptr.func = (specpdl_ptr->unwind_ptr.arg); 8. eval.c:476:unwind_body: Fprogn (body);=20 9. eval.c:462:Fprogn: val =3D eval_sub (XCAR (body));=20 10. eval.c:2090:eval_sub: if (lisp_eval_depth > max_lisp_eval_depth) = error ("Lisp nesting exceeds `max-lisp-eval-depth=E2=80=99=E2=80=9D) You can avoid this problem using `ignore-errors=E2=80=99 macro. (eval.c:1175:unwind_to_catch: lisp_eval_depth =3D = catch->lisp_eval_depth;) ```elisp (defun endless-recursive () (endless-recursive)) (unwind-protect (ignore-errors (endless-recursive)) (message "finally")) ``` > On Mar 6, 2010, at 5:30 AM, Stefan Monnier = wrote: >=20 >> If I trigger a lisp nesting error with an infinite recursion inside a >> let and an flet binding, then the effects of the flet are not undone, >> resulting in a change of binding at the top-level. >=20 >> (defun g () 'g-orig) >> (setq a 'a-orig) >=20 >> (defun h () >> (let ((a 'a-new)) >> (flet ((g () 'g-new)) >> (h)))) >> (h) ;; <-- Lisp nesting exceeds `max-lisp-eval-depth' >> (g) ;; g-new !=20 >> a ;; a-orig=20 >=20 > I can indeed reproduce it. I'm not sure yet what's going on, but it > might be due to the "Lisp nesting exceeds `max-lisp-eval-depth'" error > happening in the unwind-protect code (i.e. while undoing the `g' > binding). The explanation can't be quite so simple, but my gut = feeling > tells me it's got to do with it. >=20 >=20 > Stefan >=20 >=20 >=20 >=20 From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 11 10:50:28 2014 Received: (at 5662) by debbugs.gnu.org; 11 Nov 2014 15:50:28 +0000 Received: from localhost ([127.0.0.1]:57485 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XoDi7-0003tA-FU for submit@debbugs.gnu.org; Tue, 11 Nov 2014 10:50:28 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:56901) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XoDi3-0003sy-Bs for 5662@debbugs.gnu.org; Tue, 11 Nov 2014 10:50:24 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sABFoK0E015087; Tue, 11 Nov 2014 10:50:21 -0500 Received: by ceviche.home (Postfix, from userid 20848) id B438666100; Tue, 11 Nov 2014 10:50:22 -0500 (EST) From: Stefan Monnier To: Jinseop Kim Subject: Re: bug#5662: flet not undone on lisp nesting error Message-ID: References: <87fx4k4vty.fsf@stats.ox.ac.uk> Date: Tue, 11 Nov 2014 10:50:22 -0500 In-Reply-To: (Jinseop Kim's message of "Tue, 11 Nov 2014 11:16:48 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5122=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5122> : inlines <1512> : streams <1340700> : uri <1834257> X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 5662 Cc: Dan Davison , 5662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.9 (-) > The cause of problem is that `unwind-forms=E2=80=99 will call the `eval_s= ub=E2=80=99 > function. Of course, the `eval_sub=E2=80=99 function check for infinite > recursion. Consequently, the `unwind-protect=E2=80=99 wouldn't evaluate. Thanks for digging into it. Indeed, I think I see it now: in `unbind_to' we run the unwind_forms without updating lisp_eval_depth, so they're run with the lisp_eval_depth of the place where the signal was thrown, so if the signal was thrown because lisp_eval_depth > max_lisp_eval_depth, then the unwind forms will all fail by signaling error ("Lisp nesting exceeds `max-lisp-eval-depth'"). This said, at the time we run those unwind forms, the C stack is still at the same "very deep" state as when the error was signaled, so the lisp_eval_depth value is not completely wrong (more specifically, it would be unwise in general to simply set it to the value corresponding to the target of the longjmp, even though in your particular case you could argue that it would be right). So maybe the best solution would be to temporarily increase max-lisp-eval-depth like we do for call_debugger. Not sure how best to do that, since the way it's done in call_debugger could have too high a performance cost (it's not a problem for call_debugger since that's an exceptional situation). Stefan > You must be noted step 7~10. > Problem's steps: > 1. eval.c:1208:Funwind_protect: record_unwind_protect (unwind_body, XC= DR (args));=20 > 2. eval.c:1209:Funwind_protect: val =3D eval_sub (XCAR (args));=20 > 3. eval.c:2090:eval_sub: if (lisp_eval_depth > max_lisp_eval_depth) er= ror ("Lisp nesting exceeds `max-lisp-eval-depth'=E2=80=9D);=20 > 4. eval.c:1582:xsignal: Fsignal (error_symbol, data);=20 > 5. eval.c:1558:Fsignal: unwind_to_catch (h, unwind_data);=20 > 6. eval.c:1161:unwind_to_catch: unbind_to (handlerlist->pdlcount, Qnil= );=20 > 7. eval.c:3305:unbind_to: unwind_body // specpdl_ptr->unwind_ptr.func = (specpdl_ptr->unwind_ptr.arg); > 8. eval.c:476:unwind_body: Fprogn (body);=20 > 9. eval.c:462:Fprogn: val =3D eval_sub (XCAR (body));=20 > 10. eval.c:2090:eval_sub: if (lisp_eval_depth > max_lisp_eval_depth) e= rror ("Lisp nesting exceeds `max-lisp-eval-depth=E2=80=99=E2=80=9D) > You can avoid this problem using `ignore-errors=E2=80=99 macro. > (eval.c:1175:unwind_to_catch: lisp_eval_depth =3D catch->lisp_eval_depth= ;) > ```elisp > (defun endless-recursive () > (endless-recursive)) > (unwind-protect > (ignore-errors (endless-recursive)) > (message "finally")) > ``` >> On Mar 6, 2010, at 5:30 AM, Stefan Monnier wr= ote: >>=20 >>> If I trigger a lisp nesting error with an infinite recursion inside a >>> let and an flet binding, then the effects of the flet are not undone, >>> resulting in a change of binding at the top-level. >>=20 >>> (defun g () 'g-orig) >>> (setq a 'a-orig) >>=20 >>> (defun h () >>> (let ((a 'a-new)) >>> (flet ((g () 'g-new)) >>> (h)))) >>> (h) ;; <-- Lisp nesting exceeds `max-lisp-eval-depth' >>> (g) ;; g-new !=20 >>> a ;; a-orig=20 >>=20 >> I can indeed reproduce it. I'm not sure yet what's going on, but it >> might be due to the "Lisp nesting exceeds `max-lisp-eval-depth'" error >> happening in the unwind-protect code (i.e. while undoing the `g' >> binding). The explanation can't be quite so simple, but my gut feeling >> tells me it's got to do with it. >>=20 >>=20 >> Stefan >>=20 >>=20 >>=20 >>=20 From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 01 21:15:25 2016 Received: (at 5662) by debbugs.gnu.org; 2 Jun 2016 01:15:25 +0000 Received: from localhost ([127.0.0.1]:50300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8HEL-0007S7-Kq for submit@debbugs.gnu.org; Wed, 01 Jun 2016 21:15:25 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:33273) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8HEJ-0007LZ-T5 for 5662@debbugs.gnu.org; Wed, 01 Jun 2016 21:15:24 -0400 Received: by mail-oi0-f50.google.com with SMTP id k23so55281832oih.0 for <5662@debbugs.gnu.org>; Wed, 01 Jun 2016 18:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to; bh=vdtdU2YZD2ekjF/xdImnMpiNASy+MzSCV986dpWc09g=; b=abRKEcpE70P4OsJ0RKPSoYhYfoHOR5CSIK92g6MjhoWI9zkGcbn5cYXC9Br3EW+z+q hFU2aa9IVFy/mhWLEUrk+66BsyN0IKMyrbJtCo4XRovX/52xVo+gw/Rs5e1Q85gKXYHW ZJ/EWtyzCEPQhZgmX/DV18LB7+hqM6kHNuY/oKStBFFWWA3RuUpgWJr1tQ65K9ISho6g hJZxsZw6ZQ53lpg2b75K/XYs4aSGkANK94rI8Rdlg7+we6vuzT54lbkas9cLg3xMfVgU fLVrmfioaLh16ZbMzT0j5SNZMgnceXKeyVeU+THuH1HdHomeLaQ8al3cdDdkxosXmwYi RBig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to; bh=vdtdU2YZD2ekjF/xdImnMpiNASy+MzSCV986dpWc09g=; b=B1DA/3F2AF/gVoUPe5ulcyjiesYqublxoOIPI8nLSgbn1TORaFmcrI4r1N6RYFlAxw gJYyrSwSQeF3hNQUvBKAJa6RQzqCW36NRgF7itf9uj9/APNRA2j+GlP+3pHQXAmkZS5o aevGUR7LHF2PeG1cfpzY0StIBZ5VowOQhy3CHE3LOY8RVy8W2FPFbPyVJ/d7Da/92Z0k qOaV80kGFMzLtgjouPlV3Z//t69QcsmDM6wYbP99oglhqrKAA1f3f+/LgPI19NwA+ara 8JGKXi2HEYRwB/1Z1vU1WvoOQoJw+pKtTrscMVXrfnGpBdurOR+azKpKg0DoWuur6GDQ 3Wxg== X-Gm-Message-State: ALyK8tKRWtr5xxfQw9tQLcHi2C+MHQmvrtSQjkNf4dLZoGjBAUIdplEOceagM5qFotRTsqX51ypfTjiINVOq9w== MIME-Version: 1.0 X-Received: by 10.202.77.78 with SMTP id a75mr23327038oib.88.1464830118382; Wed, 01 Jun 2016 18:15:18 -0700 (PDT) Received: by 10.157.34.169 with HTTP; Wed, 1 Jun 2016 18:15:18 -0700 (PDT) Date: Wed, 1 Jun 2016 21:15:18 -0400 X-Google-Sender-Auth: rNnMSeTCdlhc_ujkh0QaMijCPfA Message-ID: Subject: bug#5662: flet not undone on lisp nesting error From: Noam Postavsky To: 5662@debbugs.gnu.org Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 5662 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.5 (/) found 5662 23.4 found 5662 24.3 found 5662 24.5 fixed 5662 25.0.94 close 5662 quit Seems to have been fixed in Emacs 25. I could reproduce in several earlier versions (had to add a (require 'cl) to demo code). From unknown Tue Jun 17 20:18:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 30 Jun 2016 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator