GNU bug report logs -
#17139
Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook?
Previous Next
Reported by: Daniel Colascione <dancol <at> dancol.org>
Date: Sat, 29 Mar 2014 02:19:02 UTC
Severity: normal
Done: Noam Postavsky <npostavs <at> users.sourceforge.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 03/28/2014 07:18 PM, Daniel Colascione wrote:
> Say we're using a mode derived from comint that implements completion by
> using the comint redirection functionality to send commands to the
> process associated with the comint buffer. Say we have TAB bound to
> complete-symbol. If the user presses TAB (to create a list of
> completions) and then immediately presses RET to run comint-send-input,
> we send the input to the subprocess, but don't wait for a reply. Then we
> run post-command-hook; completion-in-region--postch is on the list of
> hooks to run. This function runs completion-in-region-mode--predicate,
> which makes a hidden call to the subprocess; this hidden call involves
> writing a command waiting for a reply. But because we just sent the
> *user* line in comint-send-input, we might actually read the response to
> *that* line instead of the internal completion command, causing an
> error. The response to the internal completion command then appears in
> the comint buffer.
>
> Why can't we do the completion-in-region--postch stuff in pre-command-hook?
I think this fix works, but I'm not particularly familiar with the
completion code. Can someone review?
=== modified file 'lisp/comint.el'
--- lisp/comint.el 2014-03-22 22:12:52 +0000
+++ lisp/comint.el 2014-03-29 02:36:49 +0000
@@ -1769,6 +1769,12 @@
Similarly for Soar, Scheme, etc."
(interactive)
+ ;; If we're currently completing, stop. We're definitely done
+ ;; completing, and by sending the input, we might cause side effects
+ ;; that will confuse the code running in the completion
+ ;; post-command-hook.
+ (when completion-in-region-mode
+ (completion-in-region-mode -1))
;; Note that the input string does not include its terminal newline.
(let ((proc (get-buffer-process (current-buffer))))
(if (not proc) (user-error "Current buffer has no process")
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 8 years and 348 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.