unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer
@ 2020-10-22 21:50 Olivier Certner
  2020-10-23 12:40 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Certner @ 2020-10-22 21:50 UTC (permalink / raw)
  To: 44156

[-- 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer
  2020-10-22 21:50 bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer Olivier Certner
@ 2020-10-23 12:40 ` Lars Ingebrigtsen
  2020-10-23 13:00   ` Olivier Certner
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-23 12:40 UTC (permalink / raw)
  To: Olivier Certner; +Cc: 44156

Olivier Certner <ocert.dev@free.fr> writes:

> 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.

Thanks; looks good to me, so I've applied it to Emacs 28.

It was small enough to apply without getting copyright assignment papers
for the FSF, but any subsequent patches (that aren't very small) can't
be applied without such paperwork.  Would you be willing to sign such
paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer
  2020-10-23 12:40 ` Lars Ingebrigtsen
@ 2020-10-23 13:00   ` Olivier Certner
  2020-10-23 13:12     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Certner @ 2020-10-23 13:00 UTC (permalink / raw)
  To: 44156

> Thanks; looks good to me, so I've applied it to Emacs 28.

	Small question from a noob on GNU projects. I don't see any commit from 
you applying this.	My origin repo is: https://git.savannah.gnu.org/git/
emacs.git. Could this be because it is not the official repo? I'm looking at 
'master'. Or maybe you didn't push there yet?

-- 
Olivier Certner







^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer
  2020-10-23 13:00   ` Olivier Certner
@ 2020-10-23 13:12     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-23 13:12 UTC (permalink / raw)
  To: Olivier Certner; +Cc: 44156

Olivier Certner <ocert.dev@free.fr> writes:

> 	Small question from a noob on GNU projects. I don't see any commit from 
> you applying this.	My origin repo is: https://git.savannah.gnu.org/git/
> emacs.git. Could this be because it is not the official repo? I'm looking at 
> 'master'. Or maybe you didn't push there yet?

Yup; forgot to push.  Should be done now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-23 13:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-22 21:50 bug#44156: 26.3; ERC: Fix ERC's IBuffer format "crash" on killed server buffer Olivier Certner
2020-10-23 12:40 ` Lars Ingebrigtsen
2020-10-23 13:00   ` Olivier Certner
2020-10-23 13:12     ` Lars Ingebrigtsen

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).