Subject: package installation leaks tar-mode data buffers
From: Mattias Engdegård <[email-masked]>
To: Emacs Bug Report <[email-masked]>
Cc: Stefan Monnier <[email-masked]>
Date: Wed, 20 Aug 2025 19:50:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Apparently, package.el generates at least one leaked buffer for each package installed. From what I can tell, it's the use of tar-mode in temporary buffers, as in

  (with-temp-buffer
    (tar-mode)
    ...)

that is the problem: tar-mode will generate a helper buffer which is normally removed when the tar-mode buffer is killed, but temporary buffers inhibit the kill-buffer-hook so that never happens.

Here is a straightforward patch: explicitly return to fundamental-mode before the temporary buffer is destroyed.

An alternative would be to change tar-mode so that it doesn't rely on kill-buffer-hook to release its helper buffer. A finaliser would do, but those see so little use that it makes me a bit uneasy.

Are there other modes that may have similar problems?