Subject: Re: bug#70124: 29.3.50; Crash via indirect buffers

From: Eli Zaretskii <[email-masked]>
Date: Mon, 01 Apr 2024 15:03:59 +0300

> From: Braun Gábor <[email-masked]>
> Date: Mon, 01 Apr 2024 12:54:20 +0200
> 
> After building Emacs from source, I have added the following file
> to the build directory:
> 
> File ./bug-indirect-crash.el
> 
> ;;; bug-indirect-crash.el --- Crash via indirect buffer  -*- 
> lexical-binding: t; coding: utf-8; -*-
> 
> ;;; Commentary:
> ;; Crash Emacs by stupid use of indirect buffers.
> 
> ;;; Code:
> (let (buffer)
>   (with-temp-buffer
>     (with-current-buffer
> 	(setq buffer
> 	      (make-indirect-buffer
> 	       (current-buffer)
> 	       (generate-new-buffer-name "indirect")))
>       (setq-local kill-buffer-query-functions (list #'ignore))))
>   (with-demoted-errors "Error: %S" (set-buffer buffer))
>   (message "Current buffer: %s" (current-buffer))
>   (insert ?A))
> ;;; bug-indirect-crash.el ends here.
> 
> End of file./bug-indirect-crash.el
> 
> Below is the command I have run Emacs and the output of the 
> command:
> 
> $ src/emacs -Q --batch -l ./bug-indirect-crash.el 
> Error: (error "Marker does not point anywhere")
> Current buffer: indirect
> Fatal error 11: Segmentation fault
> 
> 
> I find the error about the marker weird, have no idea which marker 
> it
> is.
> I expect an error like "Selecting deleted buffer" instead.
> I also find the second line strange:
> (seemingly an indirect buffer is current whose base buffer is 
> killed).

Thanks.  This is already fixed on the master branch (which will
eventually become Emacs 30), where I get:

  emacs -Q --batch -l d:/usr/eli/data/bug-indirect-crash.el
  Unable to kill buffer whose indirect buffer `indirect' cannot be killed

(Btw, even on the emacs-29 branch I don't see a crash, I see an error:

  emacs -Q --batch -l d:/usr/eli/data /bug-indirect-crash.el
  Error: (error "Marker does not point anywhere")
  Current buffer: indirect

But that could be system-dependent.)

So I'm closing this bug as already solved.