From unknown Wed Jun 25 09:08:40 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#11665 <11665@debbugs.gnu.org> To: bug#11665 <11665@debbugs.gnu.org> Subject: Status: kill-buffer gives an error on killing dead buffers Reply-To: bug#11665 <11665@debbugs.gnu.org> Date: Wed, 25 Jun 2025 16:08:40 +0000 retitle 11665 kill-buffer gives an error on killing dead buffers reassign 11665 emacs submitter 11665 Vitalie Spinu severity 11665 normal tag 11665 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 10 07:00:50 2012 Received: (at submit) by debbugs.gnu.org; 10 Jun 2012 11:00:50 +0000 Received: from localhost ([127.0.0.1]:36482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sdft3-00021o-08 for submit@debbugs.gnu.org; Sun, 10 Jun 2012 07:00:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57306) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sdfsx-00021d-Nh for submit@debbugs.gnu.org; Sun, 10 Jun 2012 07:00:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdfqV-0006Wg-Rp for submit@debbugs.gnu.org; Sun, 10 Jun 2012 06:58:13 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:32929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdfqV-0006WW-OL for submit@debbugs.gnu.org; Sun, 10 Jun 2012 06:58:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdfqT-0002HK-Ta for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 06:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdfqR-0006Vt-PB for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 06:58:09 -0400 Received: from plane.gmane.org ([80.91.229.3]:34981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdfqR-0006Vh-Hs for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 06:58:07 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SdfqM-0007uj-8X for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 12:58:02 +0200 Received: from i108036.upc-i.chello.nl ([62.195.108.36]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Jun 2012 12:58:02 +0200 Received: from spinuvit by i108036.upc-i.chello.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Jun 2012 12:58:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Vitalie Spinu Subject: kill-buffer gives an error on killing dead buffers Date: Sun, 10 Jun 2012 12:57:49 +0200 Organization: EUR Lines: 89 Message-ID: <87r4tn4eoi.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: i108036.upc-i.chello.nl User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:IPt8PSp2aBarGSq4PgSfrPjnR2g= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Hi, This is a strange behavior which was not happening in previous versions of emacs. Though quite an unusual use, I decided to report it as it might be a symptom for a more serious problem. Create a buffer "test.tmp" and create an indirect buffer: (with-current-buffer (make-indirect-buffer "test.tmp" "test1") (add-hook 'kill-buffer-hook '(lambda () (setq kill-buffer-hook nil) (kill-buffer (buffer-base-buffer))) t t)) (The above triggers the killing of the base buffer when an indirect buffer is killed) Now, kill the base buffer "test.tmp", which raises: signal(error ("Buffer # is not a live buffer")) error("Buffer %s is not a live buffer" #) window-normalize-buffer(#) replace-buffer-in-windows(#) kill-buffer(#) (if (and (boundp (quote sub-kill-buffer-and-its-windows)) sub-kill-buffer-and-its-windows (fboundp (quote kill-buffer-and-its-windows))) (kill-buffer-and-its-windows (current-buffer)) (kill-buffer (current-buffer))) This doesn't occur when killing an indirect buffer. Vitalie. In GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2) of 2012-06-08 on lakoocha, modified by Debian (emacs-snapshot package, version 2:20120608-1~ppa1~precise1) Windowing system distributor `The X.Org Foundation', version 11.0.11103000 Configured using: `configure '--build' 'i686-linux-gnu' '--host' 'i686-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/' '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes' 'build_alias=i686-linux-gnu' 'host_alias=i686-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed -znocombreloc' 'CPPFLAGS=-D_FORTIFY_SOURCE=2'' Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Emacs-Lisp Minor modes in effect: TeX-PDF-mode: t highlight-parentheses-mode: t global-auto-complete-mode: t auto-complete-mode: t diff-auto-refine-mode: t global-auto-revert-mode: t keyfreq-autosave-mode: t keyfreq-mode: t sr-popviewer-mode: t shell-dirtrack-mode: t eldoc-mode: t display-time-mode: t ido-everywhere: t show-paren-mode: t savehist-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t hs-minor-mode: t From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 10 08:57:51 2012 Received: (at 11665) by debbugs.gnu.org; 10 Jun 2012 12:57:51 +0000 Received: from localhost ([127.0.0.1]:36526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdhiI-0006AW-Qi for submit@debbugs.gnu.org; Sun, 10 Jun 2012 08:57:51 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:60420) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SdhiF-0006AJ-Mp for 11665@debbugs.gnu.org; Sun, 10 Jun 2012 08:57:48 -0400 Received: (qmail invoked by alias); 10 Jun 2012 12:55:15 -0000 Received: from 62-47-53-240.adsl.highway.telekom.at (EHLO [62.47.53.240]) [62.47.53.240] by mail.gmx.net (mp020) with SMTP; 10 Jun 2012 14:55:15 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+89klK7uy8hhb5c/roG4AHHHYTT4Qc/ebhxAuHwZ jFEafTAbXDOQr5 Message-ID: <4FD49946.2040402@gmx.at> Date: Sun, 10 Jun 2012 14:55:34 +0200 From: martin rudalics MIME-Version: 1.0 To: Vitalie Spinu Subject: Re: bug#11665: kill-buffer gives an error on killing dead buffers References: <87r4tn4eoi.fsf@gmail.com> In-Reply-To: <87r4tn4eoi.fsf@gmail.com> Content-Type: multipart/mixed; boundary="------------010802080709060007060409" X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11665 Cc: 11665@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is a multi-part message in MIME format. --------------010802080709060007060409 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > Create a buffer "test.tmp" and create an indirect buffer: > > (with-current-buffer (make-indirect-buffer "test.tmp" "test1") > (add-hook 'kill-buffer-hook > '(lambda () > (setq kill-buffer-hook nil) > (kill-buffer (buffer-base-buffer))) > t t)) > > (The above triggers the killing of the base buffer when an indirect > buffer is killed) > > Now, kill the base buffer "test.tmp", which raises: > > signal(error ("Buffer # is not a live buffer")) > error("Buffer %s is not a live buffer" #) > window-normalize-buffer(#) > replace-buffer-in-windows(#) > kill-buffer(#) > (if (and (boundp (quote sub-kill-buffer-and-its-windows)) sub-kill-buffer-and-its-windows (fboundp (quote kill-buffer-and-its-windows))) (kill-buffer-and-its-windows (current-buffer)) (kill-buffer (current-buffer))) > > > This doesn't occur when killing an indirect buffer. I don't have `sub-kill-buffer-and-its-windows' so I can't repeat this easily. Anyway, here's what I suppose to happen: Killing "test.tmp" implicitly calls `kill-buffer' on "test1" because killing a base buffer kills all its indirect buffers. Killing "test1" calls `kill-buffer' on "test.tmp" because that's on the hook. Killing "test.tmp" calls `kill-buffer' on "test1" again. Killing "test1" now succeeds and returns. Killing "test.tmp" now succeeds. Killing "test1" now tries to continue with `replace-buffer-in-windows' but this fails because the buffer is no more live. I also suppose that the > kill-buffer(#) is a red herring in the sense that `kill-buffer' was actually invoked with a live buffer but when the trace was printed the buffer was already dead while `replace-buffer-in-windows' was really called with a dead buffer as argument. Basically, I could exit `replace-buffer-in-windows' when the argument buffer is not live but that's not nice. So maybe the attached patch is better. Can you try it? martin --------------010802080709060007060409 Content-Type: text/plain; name="buffer.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="buffer.c.diff" *** src/buffer.c 2012-05-29 16:13:38 +0000 --- src/buffer.c 2012-06-10 12:52:57 +0000 *************** *** 1526,1531 **** --- 1526,1535 ---- UNGCPRO; } + /* If killing the indirect buffers has killed our buffer, return. */ + if (NILP (BVAR (b, name))) + return Qnil; + /* Run replace_buffer_in_windows before making another buffer current since set-window-buffer-start-and-point will refuse to make another buffer current if the selected window does not show the current --------------010802080709060007060409-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 10 13:51:38 2012 Received: (at 11665) by debbugs.gnu.org; 10 Jun 2012 17:51:38 +0000 Received: from localhost ([127.0.0.1]:36908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdmIb-0004Hh-Ni for submit@debbugs.gnu.org; Sun, 10 Jun 2012 13:51:38 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:50460) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SdmIZ-0004HZ-0o for 11665@debbugs.gnu.org; Sun, 10 Jun 2012 13:51:36 -0400 Received: (qmail invoked by alias); 10 Jun 2012 17:49:01 -0000 Received: from 62-47-53-240.adsl.highway.telekom.at (EHLO [62.47.53.240]) [62.47.53.240] by mail.gmx.net (mp017) with SMTP; 10 Jun 2012 19:49:01 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/v44dFELPvV16T66guJ2SqFOWoXruCLPRjcBQ/2e +pvt4IKRnkOYCv Message-ID: <4FD4DE29.9040207@gmx.at> Date: Sun, 10 Jun 2012 19:49:29 +0200 From: martin rudalics MIME-Version: 1.0 To: Vitalie Spinu Subject: Re: bug#11665: kill-buffer gives an error on killing dead buffers References: <87r4tn4eoi.fsf@gmail.com> <4FD49946.2040402@gmx.at> In-Reply-To: <4FD49946.2040402@gmx.at> Content-Type: multipart/mixed; boundary="------------010303080202030903070507" X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11665 Cc: 11665@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is a multi-part message in MIME format. --------------010303080202030903070507 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit There seem more occasions where this problem could strike. Also, we should return t when we find out that the buffer name has been reset to nil under our feet. Patch attached, comments welcome. martin --------------010303080202030903070507 Content-Type: text/plain; name="buffer.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="buffer.c.diff" *** src/buffer.c 2012-05-29 16:13:38 +0000 --- src/buffer.c 2012-06-10 17:33:15 +0000 *************** *** 1493,1498 **** --- 1493,1502 ---- unbind_to (count, Qnil); } + /* If the hooks have killed the buffer, exit now. */ + if (NILP (BVAR (b, name))) + return Qt; + /* We have no more questions to ask. Verify that it is valid to kill the buffer. This must be done after the questions since anything can happen within do_yes_or_no_p. */ *************** *** 1501,1509 **** if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) return Qnil; - if (NILP (BVAR (b, name))) - return Qnil; - /* When we kill a base buffer, kill all its indirect buffers. We do it at this stage so nothing terrible happens if they ask questions or their hooks get errors. */ --- 1505,1510 ---- *************** *** 1526,1540 **** UNGCPRO; } /* Run replace_buffer_in_windows before making another buffer current since set-window-buffer-start-and-point will refuse to make another buffer current if the selected window does not show the current buffer. (Bug#10114) */ replace_buffer_in_windows (buffer); ! /* Make this buffer not be current. ! In the process, notice if this is the sole visible buffer ! and give up if so. */ if (b == current_buffer) { tem = Fother_buffer (buffer, Qnil, Qnil); --- 1527,1549 ---- UNGCPRO; } + /* If killing the indirect buffers has killed our buffer, return. */ + if (NILP (BVAR (b, name))) + return Qt; + /* Run replace_buffer_in_windows before making another buffer current since set-window-buffer-start-and-point will refuse to make another buffer current if the selected window does not show the current buffer. (Bug#10114) */ replace_buffer_in_windows (buffer); ! /* If replacing the buffer in windows has killed our buffer, ! return. */ ! if (NILP (BVAR (b, name))) ! return Qt; ! ! /* Make this buffer not be current. In the process, notice if this is ! the sole visible buffer and give up if so. */ if (b == current_buffer) { tem = Fother_buffer (buffer, Qnil, Qnil); *************** *** 1564,1574 **** kill_buffer_processes (buffer); UNGCPRO; ! /* Killing buffer processes may run sentinels which may ! have called kill-buffer. */ ! if (NILP (BVAR (b, name))) ! return Qnil; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ --- 1573,1582 ---- kill_buffer_processes (buffer); UNGCPRO; ! /* Killing buffer processes may run sentinels which may have called ! kill-buffer. */ if (NILP (BVAR (b, name))) ! return Qt; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ *************** *** 1599,1604 **** --- 1607,1616 ---- internal_delete_file (BVAR (b, auto_save_file_name)); } + /* Deleting a file could have killed our buffer. */ + if (NILP (BVAR (b, name))) + return Qt; + if (b->base_buffer) { /* Unchain all markers that belong to this indirect buffer. --------------010303080202030903070507-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 18 03:28:26 2012 Received: (at control) by debbugs.gnu.org; 18 Jun 2012 07:28:26 +0000 Received: from localhost ([127.0.0.1]:46401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SgWNt-0001Kx-94 for submit@debbugs.gnu.org; Mon, 18 Jun 2012 03:28:26 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:45940) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SgWNr-0001Kq-PL for control@debbugs.gnu.org; Mon, 18 Jun 2012 03:28:24 -0400 Received: (qmail invoked by alias); 18 Jun 2012 07:25:08 -0000 Received: from 62-47-50-47.adsl.highway.telekom.at (EHLO [62.47.50.47]) [62.47.50.47] by mail.gmx.net (mp035) with SMTP; 18 Jun 2012 09:25:08 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+WAMEZw3CWKEf31W58UIFR0s5O7dWTT6cTwrSKwW Ok4lCD+8tsdP64 Message-ID: <4FDED7D2.10103@gmx.at> Date: Mon, 18 Jun 2012 09:25:06 +0200 From: martin rudalics MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: control message for bug 11665 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) fixed 11665 24.2 From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 18 03:28:02 2012 Received: (at 11665-done) by debbugs.gnu.org; 18 Jun 2012 07:28:02 +0000 Received: from localhost ([127.0.0.1]:46398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SgWNV-0001KG-TN for submit@debbugs.gnu.org; Mon, 18 Jun 2012 03:28:02 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:44673) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SgWNT-0001K0-FV for 11665-done@debbugs.gnu.org; Mon, 18 Jun 2012 03:28:00 -0400 Received: (qmail invoked by alias); 18 Jun 2012 07:24:43 -0000 Received: from 62-47-50-47.adsl.highway.telekom.at (EHLO [62.47.50.47]) [62.47.50.47] by mail.gmx.net (mp017) with SMTP; 18 Jun 2012 09:24:43 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19PfPlTFgNPnFx6LbxioT9kXxwjJSWLe9nfCwuGv9 /NGYkoHQPFrPJ6 Message-ID: <4FDED7B5.4000008@gmx.at> Date: Mon, 18 Jun 2012 09:24:37 +0200 From: martin rudalics MIME-Version: 1.0 To: 11665-done@debbugs.gnu.org Subject: Re: bug#11665: kill-buffer gives an error on killing dead buffers References: <87r4tn4eoi.fsf@gmail.com> <4FD49946.2040402@gmx.at> <4FD4DE29.9040207@gmx.at> In-Reply-To: <4FD4DE29.9040207@gmx.at> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11665-done Cc: Vitalie Spinu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > There seem more occasions where this problem could strike. Also, we > should return t when we find out that the buffer name has been reset to > nil under our feet. Patch attached, comments welcome. Changes applied to trunk, bug closed. martin From unknown Wed Jun 25 09:08:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 16 Jul 2012 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator