Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid sometimes selecting killed buffers #87

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

Garklein
Copy link
Contributor

@Garklein Garklein commented Nov 5, 2024

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
Copy link
Contributor

walseb commented Nov 5, 2024

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
Copy link
Contributor Author

Garklein commented Nov 5, 2024

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

@Garklein
Copy link
Contributor Author

Garklein commented Nov 6, 2024

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
Copy link
Contributor

walseb commented Nov 6, 2024

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
Copy link
Contributor Author

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?

Copy link
Contributor

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually have this fix locally, I just haven't gotten around to pushing it. This is small enough it probably doesn't require any form of copyright assignment (it's also identical to my fix so it's "not creative").

@Stebalien Stebalien merged commit 369b417 into emacs-exwm:master Nov 18, 2024
@Stebalien
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants