GNU bug report logs - #76969
kill-buffer fails silently when a thread exists where it's current

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dmitry <at> gutov.dev>

Date: Wed, 12 Mar 2025 01:17:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: bug-gnu-emacs <at> gnu.org
Subject: kill-buffer fails silently when a thread exists where it's current
Date: Wed, 12 Mar 2025 03:16:08 +0200
This stems from a private bug report about diff-hl when it uses a thread 
to update the fringe highlights.

To reproduce:

  1. Install, enable diff-hl-mode.
  2. (setq diff-hl-update-async t)
  3. Visit a code buffer in a (e.g.) Git repo, save it.
  4. Make an edit, don't save.
  5. Evaluate this:

  (progn
    (save-buffer)
    (kill-buffer))

Current:

The result is that the buffer is not killed. And that happens silently, 
no errors or anything. Only further examination and reading the sources 
led to understanding the reason.

Expected:

It probably should be killed. After the thread is signaled some error 
(perhaps) and is aborted. And if the buffer can't be killed, 
'kill-buffer' itself should exit with an error.

As I understand the behavior is old (2013) and comes from the 
'thread_check_current_buffer' call in Fkill_buffer. But it's not 
mentioned in kill-buffer's docstring or the manual.

Alternative repro:

If you don't have diff-hl installed, you could replace 1 and 2 with:

  (defun foo ()
    (make-thread (lambda () (sleep-for 0.1))))

  (add-hook 'after-save-hook #'foo)




This bug report was last modified 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.