unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 33034@debbugs.gnu.org
Subject: bug#33034: `unwind-protect' cleanup form is not executed if body dies in stack overflow
Date: Sat, 13 Oct 2018 16:02:09 +0200	[thread overview]
Message-ID: <CAG7BpaoD0Pa3GxDn0VWJy6uJg0giTCQjPZ01uN8t-tZfxVTFDQ@mail.gmail.com> (raw)
In-Reply-To: <83bm7yuiqx.fsf@gnu.org>

(defvar global-test nil)
(unwind-protect
    (let ((global-test t))
      (message "inside, global-test = %s" global-test)
      (error "test"))
  (message "in cleanup, global-test = %s" global-test))

This gives the following output (outside the error):
    inside, global-test = t
    in cleanup, global-test = nil

So, global variables are unwound, but stack is not? This doesn't make
much sense to me.

Besides, what is the purpose of current implementation? Current state
has at least one disadvantage, highlighted by this bug: cleanup forms
after a stack overflow error always fail to work, because stack is
still full. Are there any advantages? I feel like it is more of
coincidence than deliberate decision. Would fixing it break backwards
compatibility?
On Sat, 13 Oct 2018 at 14:35, Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Paul Pogonyshev <pogonyshev@gmail.com>
> > Date: Sat, 13 Oct 2018 13:38:11 +0200
> > Cc: 33034@debbugs.gnu.org
> >
> > OK, but why does it hit the limit? Logically, by the time cleanup form
> > is called, all the (overflow) stack frames should be removed and the
> > cleanup form should see practically empty stack. It shouldn't be much
> > different from calling cleanup without overflowing the stack to begin
> > with.
>
> I don't think your expectation, that the stack should be unwound
> before the cleanup runs, is correct.  The implementation calls the
> cleanup forms before it jumps to top-level, and I see nothing in the
> documentation to promise anything different.





  reply	other threads:[~2018-10-13 14:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13 10:07 bug#33034: `unwind-protect' cleanup form is not executed if body dies in stack overflow Paul Pogonyshev
2018-10-13 10:29 ` Eli Zaretskii
2018-10-13 10:35   ` Paul Pogonyshev
2018-10-13 10:45     ` Eli Zaretskii
2018-10-13 10:52       ` Paul Pogonyshev
2018-10-13 11:01         ` Eli Zaretskii
2018-10-13 11:29           ` Eli Zaretskii
2018-10-13 11:38             ` Paul Pogonyshev
2018-10-13 12:35               ` Eli Zaretskii
2018-10-13 14:02                 ` Paul Pogonyshev [this message]
2018-10-14 17:02 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG7BpaoD0Pa3GxDn0VWJy6uJg0giTCQjPZ01uN8t-tZfxVTFDQ@mail.gmail.com \
    --to=pogonyshev@gmail.com \
    --cc=33034@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).