unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33034: `unwind-protect' cleanup form is not executed if body dies in stack overflow
@ 2018-10-13 10:07 Paul Pogonyshev
  2018-10-13 10:29 ` Eli Zaretskii
  2018-10-14 17:02 ` Paul Eggert
  0 siblings, 2 replies; 11+ messages in thread
From: Paul Pogonyshev @ 2018-10-13 10:07 UTC (permalink / raw)
  To: 33034

To reproduce:

    (defun overflow ()
      (overflow))
    (defun test ()
      (interactive)
      (message "BEFORE")
      (unwind-protect
          (overflow)
        (message "CLEANUP")))

Invocation of `test' never issues message "CLEANUP", whether it is run
interactively or non-interactively.

By comparison, if you _catch_ the error with `condition-case':

    (defun test-2 ()
      (interactive)
      (message "BEFORE")
      (unwind-protect
          (ignore-errors (overflow))
        (message "CLEANUP")))

then cleanup form is executed properly.

But if your error catcher is "above" the `unwind-protect' form, the
cleanup is not executed again, even though the error is eaten as
expected:

    (defun test-3 ()
      (interactive)
      (message "BEFORE")
      (ignore-errors
        (unwind-protect
            (overflow)
          (message "CLEANUP"))))

This is a perfect way to screw up your Emacs permanently (until full
restart): when some `unwind-protect' cleanups are not run, you can be
left with unexpected function advices, permanently altered global
state etc., without any good way to undestand what's wrong.

Paul





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-14 17:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-10-14 17:02 ` Paul Eggert

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).