all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33145: 27.0.50; rcirc race receives duplicate messages
@ 2018-10-25  3:02 Basil L. Contovounesios
  2018-10-25  3:07 ` Basil L. Contovounesios
  0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2018-10-25  3:02 UTC (permalink / raw)
  To: 33145

Currently, rcirc-filter clears the accumulator variable
rcirc-process-output only after each of its constituent lines has been
fed to rcirc-process-server-response, which in turn runs the abnormal
hook rcirc-receive-message-functions.

If this hook contains a function which allows process filters to be run,
e.g. by way of accept-process-output, and if process output arrives soon
enough, then rcirc-filter might be called more than once before its
previous invocation has managed to clear rcirc-process-output.

In other words, subsequent invocations may see process output that is
already being handled by previous invocations, thus potentially printing
duplicate messages in the process buffer.

Patch addressing this to follow.

Thanks,

-- 
Basil

In GNU Emacs 27.0.50 (build 31, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-10-24 built on thunk
Repository revision: 00027ff9d0f646662458bdb47cc7e2214f439698
Windowing system distributor 'The X.Org Foundation', version 11.0.12001000
System Description: Debian GNU/Linux buster/sid

Configured using:
 'configure --config-cache --prefix=/home/blc/.local --with-mailutils
 --with-x-toolkit=lucid --with-modules --with-file-notification=yes
 --with-x 'CC=ccache gcc' 'CFLAGS=-O2 -march=native -pipe''

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS
GLIB NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT
ZLIB TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON LCMS2 GMP





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

* bug#33145: 27.0.50; rcirc race receives duplicate messages
  2018-10-25  3:02 bug#33145: 27.0.50; rcirc race receives duplicate messages Basil L. Contovounesios
@ 2018-10-25  3:07 ` Basil L. Contovounesios
  2018-11-03  8:47   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2018-10-25  3:07 UTC (permalink / raw)
  To: 33145

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Avoid-race-in-rcirc-process-filter-bug-33145.patch --]
[-- Type: text/x-diff, Size: 1607 bytes --]

From b5af2a63844fcdceab4520dae9c298c240a07df2 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Thu, 25 Oct 2018 03:35:57 +0100
Subject: [PATCH] Avoid race in rcirc process filter (bug#33145)

* lisp/net/rcirc.el (rcirc-filter): Clear rcirc-process-output
before processing its constituent lines.  Otherwise, if rcirc-filter
runs again before the last rcirc-process-server-response is
finished, the contents of rcirc-process-output could be duplicated.
---
 lisp/net/rcirc.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index fe9c71a21c..893ff5829b 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -751,12 +751,12 @@ rcirc-filter
   (with-rcirc-process-buffer process
     (setq rcirc-last-server-message-time (current-time))
     (setq rcirc-process-output (concat rcirc-process-output output))
-    (when (= (aref rcirc-process-output
-                   (1- (length rcirc-process-output))) ?\n)
-      (mapc (lambda (line)
-              (rcirc-process-server-response process line))
-            (split-string rcirc-process-output "[\n\r]" t))
-      (setq rcirc-process-output nil))))
+    (when (= ?\n (aref rcirc-process-output
+                       (1- (length rcirc-process-output))))
+      (let ((lines (split-string rcirc-process-output "[\n\r]" t)))
+        (setq rcirc-process-output nil)
+        (dolist (line lines)
+          (rcirc-process-server-response process line))))))
 
 (defun rcirc-reschedule-timeout (process)
   (with-rcirc-process-buffer process
-- 
2.19.1


[-- Attachment #2: Type: text/plain, Size: 131 bytes --]


"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> Patch addressing this to follow.

I attach said patch.

Thanks,

-- 
Basil

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

* bug#33145: 27.0.50; rcirc race receives duplicate messages
  2018-10-25  3:07 ` Basil L. Contovounesios
@ 2018-11-03  8:47   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2018-11-03  8:47 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 33145-done

> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Thu, 25 Oct 2018 04:07:33 +0100
> 
> > Patch addressing this to follow.
> 
> I attach said patch.

Thanks, pushed to the emacs-26 branch.





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

end of thread, other threads:[~2018-11-03  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-25  3:02 bug#33145: 27.0.50; rcirc race receives duplicate messages Basil L. Contovounesios
2018-10-25  3:07 ` Basil L. Contovounesios
2018-11-03  8:47   ` Eli Zaretskii

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.