From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jinseop Kim Newsgroups: gmane.emacs.bugs Subject: bug#5662: flet not undone on lisp nesting error Date: Tue, 11 Nov 2014 11:16:48 +0900 Message-ID: References: <87fx4k4vty.fsf@stats.ox.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1415675311 1525 80.91.229.3 (11 Nov 2014 03:08:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Nov 2014 03:08:31 +0000 (UTC) Cc: Dan Davison To: 5662@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 11 04:08:20 2014 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 1Xo1oa-0004a4-BT for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Nov 2014 04:08:20 +0100 Original-Received: from localhost ([::1]:46530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xo1oZ-0003cG-RE for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Nov 2014 22:08:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xo1oQ-0003c7-7U for bug-gnu-emacs@gnu.org; Mon, 10 Nov 2014 22:08:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xo1oJ-0007PO-0u for bug-gnu-emacs@gnu.org; Mon, 10 Nov 2014 22:08:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xo1oI-0007PG-V5 for bug-gnu-emacs@gnu.org; Mon, 10 Nov 2014 22:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xo1oI-0008PI-D4 for bug-gnu-emacs@gnu.org; Mon, 10 Nov 2014 22:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jinseop Kim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Nov 2014 03:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5662 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5662-submit@debbugs.gnu.org id=B5662.141567523432259 (code B ref 5662); Tue, 11 Nov 2014 03:08:02 +0000 Original-Received: (at 5662) by debbugs.gnu.org; 11 Nov 2014 03:07:14 +0000 Original-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 Original-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==; Original-Received: from [98.139.212.153] by nm8.bullet.mail.bf1.yahoo.com with NNFMP; 11 Nov 2014 02:16:54 -0000 Original-Received: from [98.139.211.202] by tm10.bullet.mail.bf1.yahoo.com with NNFMP; 11 Nov 2014 02:16:54 -0000 Original-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- In-Reply-To: X-Mailer: Apple Mail (2.1990.1) X-Mailman-Approved-At: Mon, 10 Nov 2014 22:07:12 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:95855 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