Subject: Re: bug#39344: 28.0.50; Gnus: Selecting deleted buffer

From: Stephen Berman <[email-masked]>
Date: Wed, 29 Jan 2020 14:56:13 +0100

On Wed, 29 Jan 2020 14:42:26 +0100 Robert Pluim <[email-masked]> wrote:

>>>>>> On Wed, 29 Jan 2020 14:33:20 +0100, Stephen Berman
>> <[email-masked]> said:
>
>     Stephen> On Wed, 29 Jan 2020 14:25:10 +0100 Robert Pluim
>     Stephen> <[email-masked]> wrote:
>     >>>>>>> On Wed, 29 Jan 2020 14:07:16 +0100, Stephen Berman
>     >> <[email-masked]> said:
>     Stephen> I see this too.  The patch below appears to fix it for me, but I don't
>     Stephen> know if it's just a workaround.
>     >> 
>     >> That canʼt be right. 'gnus-buffers' already checks 'buffer-live-p'.
>
>     Stephen> Hm, odd, because when I stepped through gnus-clear-system, the error
>     Stephen> occurred here:
>
>     Stephen>    ;; Kill Gnus buffers.
>     Stephen>    (do-auto-save t)
>     Stephen>    (dolist (buffer (gnus-buffers))
>     Stephen>      (with-current-buffer buffer   <===
>
>     Stephen> and after adding the buffer-live-p check before that line, the error no
>     Stephen> longer occurs.
>
> So one of Gnus' buffers is being killed in the middle of that
> dolist. The only way I can see that happening is if the same buffer is
> in there twice, in which case the following would work as well.
>
> diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
> index 6df26b4af8..2fc14c5fff 100644
> --- a/lisp/gnus/gnus.el
> +++ b/lisp/gnus/gnus.el
> @@ -671,7 +671,7 @@ gnus-kill-buffer
>  
>  (defun gnus-buffers ()
>    "Return a list of live Gnus buffers."
> -  (setq gnus-buffers (seq-filter #'buffer-live-p gnus-buffers)))
> +  (setq gnus-buffers (delete-dups (seq-filter #'buffer-live-p gnus-buffers))))
>  
>  (defalias 'gnus-prune-buffers #'gnus-buffers)

Yes, that seems to fix the problem too.

Steve Berman