unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Olivier Certner <ocert.dev@free.fr>
To: 44156@debbugs.gnu.org
Subject: bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer
Date: Thu, 22 Oct 2020 23:50:27 +0200	[thread overview]
Message-ID: <1823357.Ei5Gdb227I@ravel> (raw)

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

Applies to 26.3, but also to all more recent versions as well.

Bug trigger:
1. Load ERC (e.g., open some IRC connection).
2. Open some channel or query, to have another ERC buffer.
3. Quit the server.
4. Make sure to kill the server buffer, if still there.
5. Launch ibuffer (e.g., type "M-x ibuffer"). Display stops mid-line on a line 
listing some ERC buffer linked to the quit server. Further buffer updates 
(typing 'g') trigger a crash for another reason (another fix to follow-up).

Root cause:
The erc-ibuffer's server column code will return nil in this case, since
the buffer associated to its process has been killed, making the server
information inacessible, and this is not tested properly.

Patch:
Attached.

-- 
Olivier Certner

[-- Attachment #2: 0001-ERC-Fix-ERC-s-IBuffer-format-crash-on-killed-server-.patch --]
[-- Type: text/x-patch, Size: 2430 bytes --]

From e10325a729d39b32dcf83de17a7f19e5152ec496 Mon Sep 17 00:00:00 2001
From: Olivier Certner <ocert.dev@free.fr>
Date: Thu, 22 Oct 2020 23:14:22 +0200
Subject: [PATCH] ERC: Fix ERC's IBuffer format "crash" on killed server buffer

* lisp/erc/erc-ibuffer.el (erc-server-name): Fix a crash when
displaying (or updating) an IBuffer buffer using ERC's first IBuffer
format.  This happens when one ERC buffer has its associated server
buffer killed, e.g., voluntarily or automatically after server
disconnection when `erc-kill-server-buffer-on-quit' is set to t.  The
culprit is the "Server" column, which returns nil in this case.
Display "(closed)" instead.
---
 ChangeLog.3             | 13 +++++++++++++
 lisp/erc/erc-ibuffer.el | 12 ++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/ChangeLog.3 b/ChangeLog.3
index ec2d3f8d46..65c846a307 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -1,3 +1,16 @@
+2020-10-22  Olivier Certner  <ocert.dev@free.fr>
+
+	ERC: Fix ERC's IBuffer format "crash" on killed server buffer
+
+	* lisp/erc/erc-ibuffer.el (erc-server-name): Fix a crash when
+	displaying (or updating) an IBuffer buffer using ERC's first
+	IBuffer format.  This happens when one ERC buffer has its
+	associated server buffer killed, e.g., voluntarily or
+	automatically after server disconnection when
+	`erc-kill-server-buffer-on-quit' is set to t.  The culprit is the
+	"Server" column, which returns nil in this case.  Display
+	"(closed)" instead.
+
 2020-08-03  Phil Sainty  <psainty@orcon.net.nz>
 
 	lisp/so-long.el: Improve support for major mode hooks
diff --git a/lisp/erc/erc-ibuffer.el b/lisp/erc/erc-ibuffer.el
index 7aee7705ff..556a25e3e7 100644
--- a/lisp/erc/erc-ibuffer.el
+++ b/lisp/erc/erc-ibuffer.el
@@ -92,10 +92,14 @@
     " "))
 
 (define-ibuffer-column erc-server-name (:name "Server")
-  (if (and erc-server-process (processp erc-server-process))
-      (with-current-buffer (process-buffer erc-server-process)
-	(or erc-server-announced-name erc-session-server))
-    ""))
+  (or
+   (when (and erc-server-process (processp erc-server-process))
+     (let ((buffer (process-buffer erc-server-process)))
+       (if (buffer-live-p buffer)
+         (with-current-buffer buffer
+           (or erc-server-announced-name erc-session-server))
+         "(closed)")))
+   ""))
 
 (define-ibuffer-column erc-target (:name "Target")
   (if (eq major-mode 'erc-mode)
-- 
2.24.1


             reply	other threads:[~2020-10-22 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 21:50 Olivier Certner [this message]
2020-10-23 12:40 ` bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer Lars Ingebrigtsen
2020-10-23 13:00   ` Olivier Certner
2020-10-23 13:12     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1823357.Ei5Gdb227I@ravel \
    --to=ocert.dev@free.fr \
    --cc=44156@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).