Skip to content

Stop the suite leaving foreign buffers current - #2175

Open
bbatsov wants to merge 1 commit into
masterfrom
test/fix-buffer-leaks
Open

Stop the suite leaving foreign buffers current#2175
bbatsov wants to merge 1 commit into
masterfrom
test/fix-buffer-leaks

Conversation

@bbatsov

@bbatsov bbatsov commented Aug 25, 2026

Copy link
Copy Markdown
Owner

A spec that switches buffers without putting the old one back leaves it current for everything after it. Most specs don't care, so the leak sits unnoticed until one that reads ambient buffer state runs next and fails - which is exactly how projectile-default-compilation-command (it asserts on (point)) started failing on Emacs 30.2 and nowhere else earlier this week.

dev/buffer-leaks.el reported eleven. The fix is in three places rather than eleven:

  • projectile-test-with-sandbox restores the current buffer, covering everything built on it
  • the session specs remember and restore around each spec, since they lay out windows and rearrange tabs deliberately
  • one switch spec resolved a relative file name after switch-to-buffer had changed default-directory under it, and was passing only by accident of ambient state - it now resolves the path up front

Zero leaks reported after this, suite still 1518 green.

A spec that switches buffers without putting the old one back leaves it
current for everything that runs after it.  Most specs don't care, so
such a leak sits unnoticed until one that reads ambient buffer state runs
next and fails - which is how `projectile-default-compilation-command'
(it asserts on `(point)') started failing on Emacs 30.2 and nowhere else.

`dev/buffer-leaks.el' reported eleven of them.  The fix is in three
places rather than eleven: `projectile-test-with-sandbox' now restores
the current buffer, which covers everything built on it; the session
specs remember and restore around each spec, since they lay out windows
and rearrange tabs on purpose; and one switch spec was resolving a
relative file name after `switch-to-buffer' had already changed
`default-directory' out from under it, so it now resolves the path up
front.

Zero leaks reported after this.
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.

1 participant