perspective-el icon indicating copy to clipboard operation
perspective-el copied to clipboard

`persp-delete-frame` alters windows of other frames when killing frame with dedicated window

Open Sorixelle opened this issue 3 years ago • 1 comments

When closing a frame that only contains one dedicated window, messages similar to the following get logged in *Messages*:

Error during redisplay: (run-hook-with-args persp-delete-frame #<dead frame testing 0x8d099f8>) signaled (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
Error during redisplay: (run-hook-with-args persp-delete-frame #<dead frame testing 0x8d099f8>) signaled (error "#<window 467> is not a live window") [225 times]

This also seems to coincide with either a window getting removed from another frame, or the window being changed to some other buffer if it's the only window on the frame.

I've been able to reproduce this in Emacs 28.2. I first noticed it in an EXWM environment (since EXWM creates a new frame with a dedicated window for "floating" X windows), but I've been able to reproduce it in a regular Emacs environment as well.

Steps to reproduce:

  1. Open a new frame (C-x 5 2)
  2. Open a new buffer in that frame's window (C-x b <some buffer name>)
  3. Set the window in that frame to be dedicated M-: (set-window-dedicated-p (selected-window) t)
  4. Delete the frame (C-x 5 0)
  5. Note the changes in other open frames, and the errors logged in *Messages*.

Suspected cause The infinite loop appears to be as follows:

  1. persp-delete-frame -> persp-kill
  2. persp-kill -> persp-remove-buffer
  3. persp-remove-buffer -> kill-buffer if the buffer doesn't exist in other perspectives
  4. kill-buffer -> replace-buffer-in-windows
  5. replace-buffer-in-windows -> delete-frame since the window is dedicated, and the only window in the frame
  6. delete-frame runs delete-frame-functions, which contains persp-delete-frame

Sorixelle avatar Jan 27 '23 02:01 Sorixelle

Thank you for the detailed bug report. I'm swamped right now, but will try to find time to take a look in the next couple of weeks.

gcv avatar Feb 02 '23 17:02 gcv