emacs-exwm / exwm

Emacs X Window Manager
https://elpa.gnu.org/packages/exwm.html
GNU General Public License v3.0
278 stars 14 forks source link

Avoid sometimes selecting killed buffers #87

Closed Garklein closed 5 days ago

Garklein commented 2 weeks ago

I am unable to reliably reproduce this, but occasionally, window-prev-buffers returns a killed buffer. Then, when EXWM tries to switch to it, it gives an error, and workspace switching locks up.

walseb commented 2 weeks ago

I get a similar error which might be related. It occurs in the same function that you edited if I recall correctly. Some EXWM timer errors that it tried to select a killed buffer. I will post the backtrace here next time I see it.

It locks up Emacs for me too but I'm usually able to make it stop by removing all EXWM buffers from the screen and then letting the code continue by closing the backtrace buffer.

Garklein commented 2 weeks ago

That sounds like the same thing that happens to me, could be the same issue.

Garklein commented 2 weeks ago

Steps to reproduce:

  1. open up an X window A
  2. open up another X window B in the same window, in the same workspace
  3. switch to another workspace
  4. switch to buffer B
  5. delete buffer B
  6. switch back to the original workspace

If you check window-prev-buffers, the killed buffer should be in there, and you should get the error.

Also, I suspect that window-prev-buffers is never supposed to have a killed buffer in it (from testing the above with normal buffers instead of X windows), so this may be a deeper issue inside EXWM.

walseb commented 2 weeks ago

I got the error message again today. It was triggered when a game on Steam tried to launch a bunch of windows. It seems to have been triggered by my timer initially, or it's unrelated. I was in several recursive edits at the time, so I cut those out of the backtrace:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  exwm-layout--refresh-workspace(#<frame GNU Emacs 0x399f1c38>)
  exwm-layout--refresh()
  redisplay_internal\ \(C\ function\)()
  #<subr recursive-edit>()
  ...
  my/pacing-reminder()
  apply(my/pacing-reminder nil)
  timer-event-handler([t 26411 36077 187267 nil my/pacing-reminder nil nil 828000 nil])

I do disable exwm windows, so that might have contributed to the error:

(setq exwm-manage-force-tiling t)
Garklein commented 6 days ago

I don't know much about Emacs or EXWM internals, but I've been poking around a bit.

It looks like when buffers are killed, they should be removed from previous and next buffer lists: https://github.com/emacs-mirror/emacs/blob/7ded1064cf4d9fde32c7a89473ef9476520cd556/src/buffer.c#L2014-L2019

Does anyone have any idea why these killed EXWM buffers still show up in window-prev-buffers?

Stebalien commented 5 days ago

Does anyone have any idea why these killed EXWM buffers still show up in window-prev-buffers?

That is a good question and... I have no idea. It's possibly an upstream bug but it can't hurt to fix it here as well.