From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Mar 2014 02:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 17139@debbugs.gnu.org X-Debbugs-Original-To: "bug-gnu-ema >> bug-emacs" Received: via spool by submit@debbugs.gnu.org id=B.139605951527075 (code B ref -1); Sat, 29 Mar 2014 02:19:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Mar 2014 02:18:35 +0000 Received: from localhost ([127.0.0.1]:55290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTiqw-00072c-In for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38351) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTiqu-00072U-N3 for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTiqo-000539-38 for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqn-000535-WC for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqh-0005j7-J9 for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTiqb-00052C-4x for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:19 -0400 Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:51548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqa-000527-Pw for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=ZTmJqsy5J1CRlx0W4DsFJupJtD7rPRcJZWQsy8AB3Uk=; b=eosg6Ga7Zl+w97lKiDAmuK8gYLfPZ5nsBSxwqArUMMoqbO332HOreMT2PBpmY9GzhwwAHfBABldXmSm5B73E7W4o/7s6+/oSK4VOy4NbRk4mmJk4g73wGKLimpdeC40ytmhZUkZFkt5MiME6ul0VxWfpu6fr5hyv8H2cr7bdOi89LLbgUKGLGvDEiqo6QSKjekir5Bxhb55hrWw7fHvDZVEecbtJ0syVKv2PGLFpfryRUcyzl4mWel08l1cCDGcxhuySDl90znYt6b9xao/muhE4N3n50aXmN0uc+CrsvoBzLdKpyZkJ8DmjiKHzYtPbWiWgEPHS/Pitegp+VX7opg==; Received: from ip-64-134-226-73.public.wayport.net ([64.134.226.73] helo=[192.168.5.69]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WTiqZ-00015H-KX for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 19:18:11 -0700 Message-ID: <53362D5C.2070502@dancol.org> Date: Fri, 28 Mar 2014 19:18:04 -0700 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-hoo= k? --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTNi1cAAoJEMAaIROpHW7IUpYP/3Y27FKf0oI0UZAc2Q93tBtr g96Fkqb92U+VK6Ax/RGewhSVIt/EuJ8KHf+py/XZDvb1byrQx518H9t3HY0+Q7C7 5XNRBflLgwH72apXkOiasCUNA3fbDdXTWrw9+QDmE6Efqs+XSPud/ebRiAsk2NoC Cy2sgfU5PGWNV6Y7dltyb+KVC8VNd+m3Wcq7TxkFILha+uN4BXX0+qw8pIHQKvbD fYi8euKhDEN4kYYngAANEbDnbna2UbXjr1Rl7FDozsnhuWScHN85ujTJZzKXg3YW qTP1+xdCXU2rHvEAYckynKf36go9bg97x7KAk/oL1wFoOcsl6vz6mAZLZAxOFMq0 wkIUDEqIpNTwoi1C3zXa3CKXpfw54mK8rN4LexDDygQVLS9O9E7kpequgV+/rwGS Pw86KP0biV/QOLVlPMA05Xq65AVmV4aNo9+l3wlvnWCzfQGCssEGlJH8ZtCqufRb geidX7FcBPVdWvFPj5L//2hlp9edCuCdUyNnGOQzIPNv/DLGLA/Dc3FLuTrmxlGJ 0GXbhWXk02NwQW7h+SMYmpWuQ3tXmERDsyA5ytvuhCGOh5wuxzP5n5wY7rTGUJrF djfzzONHqar43KhPpntdpUAPKng+GR9ZdViOKsmHvVi/Ez+9MCKoeTRn/jKsFqgI 8K2Ka1yBSbt0K5amtY8w =qGNB -----END PGP SIGNATURE----- --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf-- From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Mar 2014 02:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 17139@debbugs.gnu.org Received: via spool by 17139-submit@debbugs.gnu.org id=B17139.139606080529439 (code B ref 17139); Sat, 29 Mar 2014 02:41:02 +0000 Received: (at 17139) by debbugs.gnu.org; 29 Mar 2014 02:40:05 +0000 Received: from localhost ([127.0.0.1]:55303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTjBj-0007ek-TU for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:40:04 -0400 Received: from dancol.org ([96.126.100.184]:39379) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTjBd-0007e8-CJ for 17139@debbugs.gnu.org; Fri, 28 Mar 2014 22:39:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=s/Jkj2YYUGSMOoqyAlWld6y3l9q4DCTHDPlSTH4F/Dc=; b=ayL4C7Vte5yqoy3fmOiHT0ZJNdR2V72gHlakWGQp+LeFEy3MFN7oW6XO8FpL3eVPNHIclTG9U5Ti3CakBgyLEqF4ft9nAuaGmt34LcupYIANuJsLtuI97c/814TBmFzT6jaV36/ZOgUXMoWn6Ud0UmLMuRDQRiSzI/CedxyH/eL1rk41apvC0rkPKuyHdpWwLInsCI90yc5Or27ZiFmNb71JZlcxYxI0I0UZPRGGRMW7TVQXwAg9Kt2Z7DNfpI3Mt8esZbGVntshQRkYDxBZ1kxKo7N/ov5tIfY1AnwsaKXJsSwigILEbqKOhI7bEthcBleRrIaWWgd1aaQtIJyXJA==; Received: from ip-64-134-226-73.public.wayport.net ([64.134.226.73] helo=[192.168.5.69]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WTjBZ-0001AU-RA for 17139@debbugs.gnu.org; Fri, 28 Mar 2014 19:39:56 -0700 Message-ID: <53363260.9060207@dancol.org> Date: Fri, 28 Mar 2014 19:39:28 -0700 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 References: <53362D5C.2070502@dancol.org> In-Reply-To: <53362D5C.2070502@dancol.org> X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pOwqnwUrmMcr7tJqCjiup4PEDxeQFqwJx" X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pOwqnwUrmMcr7tJqCjiup4PEDxeQFqwJx Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/28/2014 07:18 PM, Daniel Colascione wrote: > Say we're using a mode derived from comint that implements completion b= y > 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 w= e > 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 t= o > *that* line instead of the internal completion command, causing an > error. The response to the internal completion command then appears in > the comint buffer. >=20 > Why can't we do the completion-in-region--postch stuff in pre-command-h= ook? I think this fix works, but I'm not particularly familiar with the completion code. Can someone review? =3D=3D=3D 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") --pOwqnwUrmMcr7tJqCjiup4PEDxeQFqwJx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTNjJgAAoJEMAaIROpHW7IjV0P/1sPhPJSTmaHyJO51+AnVtsN kiCKSrIx4mu/mIBR70Qb2EYE7g5WTfxAD4B51VLUKCVFYLt2awyF9zvgURfJsSFD UoHbc3shzfNUPPt4fTEIK18M8WAjV6HW/5kJ9P8A5YdlNhLeFCC3/pVlaejiuJWP z88y9s5zym2YKJVcImT4EIBP5PFqFT1I0vVX+i+dEz8xfFebn+ubD5R8UhqPAJVC 56c5rxaZwaCeoiqYNiFe3SakTrAR39KFbmct/ePv/8L7yL2q4a0HmCOD2lFcDcSx fVjqCicuASTU+ksTm+xP4K/He/jEAY8RlT9gg7oT83GFmR17ZUgbff5oscXvMKP0 naOXMa6Mpk6XVnnV2/3Po9UXrzwDP+o+b2TOFtXMii2l+c8LWG593Q2Obm/ojJNF SjwyPs5C0i66m7SeAZUASijQqSm92kVwmYypaD2EP6pFDC//CjpVShCeeKVvL4Q2 M6b4pUa2NaWMWcKw4AtGx9Gf0qemwJQdbtcR8Bd6DiemnQ3tk8Doc2y99Xder2Hu Kj11F7UjPwqYYU+jbb9IcrKQSYRDdKCHLtbpOg4I0U9adGruO+AcpYDF4qpuZ5Lc VAB08/XsMKe2TvX+51jTqAdgmoCeZu4mQGonFT22V4e0MSaPWOoL1dAy36D9zwZc SOuE7L/neS6KkLIfsTy8 =neNB -----END PGP SIGNATURE----- --pOwqnwUrmMcr7tJqCjiup4PEDxeQFqwJx-- From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Mar 2014 21:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Daniel Colascione Cc: 17139@debbugs.gnu.org Received: via spool by 17139-submit@debbugs.gnu.org id=B17139.13962155727587 (code B ref 17139); Sun, 30 Mar 2014 21:40:01 +0000 Received: (at 17139) by debbugs.gnu.org; 30 Mar 2014 21:39:32 +0000 Received: from localhost ([127.0.0.1]:57346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUNRz-0001yH-C6 for submit@debbugs.gnu.org; Sun, 30 Mar 2014 17:39:32 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:59502) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUNRx-0001y6-J8 for 17139@debbugs.gnu.org; Sun, 30 Mar 2014 17:39:30 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s2ULdPU0030860; Sun, 30 Mar 2014 17:39:25 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id E9DFFAE927; Sun, 30 Mar 2014 17:39:19 -0400 (EDT) From: Stefan Monnier Message-ID: References: <53362D5C.2070502@dancol.org> <53363260.9060207@dancol.org> Date: Sun, 30 Mar 2014 17:39:19 -0400 In-Reply-To: <53363260.9060207@dancol.org> (Daniel Colascione's message of "Fri, 28 Mar 2014 19:39:28 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4897=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4897> : inlines <663> : streams <1147929> : uri <1715186> X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) >> 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; Using the subprocess from completion-in-region--postch sounds like a problem/bug, indeed. Why do we(I?) do that? >> Why can't we do the completion-in-region--postch stuff in pre-command-hook? Because pre-command-hook would come even later (it would only disable completion-in-region-mode at the beginning of the next command after RET). > + ;; 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)) I see you installed it, thanks, I think it's OK. But I'd also like to know why we contact the subprocess from completion-in-region--postch, because that's risky. Stefan From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Mar 2014 21:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 17139@debbugs.gnu.org Received: via spool by 17139-submit@debbugs.gnu.org id=B17139.13962162108631 (code B ref 17139); Sun, 30 Mar 2014 21:51:02 +0000 Received: (at 17139) by debbugs.gnu.org; 30 Mar 2014 21:50:10 +0000 Received: from localhost ([127.0.0.1]:57355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUNcH-0002F8-6n for submit@debbugs.gnu.org; Sun, 30 Mar 2014 17:50:09 -0400 Received: from dancol.org ([96.126.100.184]:50944) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUNcB-0002Ej-Fu for 17139@debbugs.gnu.org; Sun, 30 Mar 2014 17:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:In-Reply-To:References:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=ktEoY3yyGPMJd+iwIXPiOnSilTkEOdUHU9uD3ELsX9E=; b=mYbPEppKrfvM+6TgjrEZtGVC1xUmBs1JUb0Eh/yvi/jPrbIbBE4wDbHX25z+labpKafJt2LSbk2RLY1Cje0QXXZ0bJglh83Hpty2IelEHhviYNTCWvnHyCVZXmqlUBoCnbONvu+aan2W1giNlLURMcIxkffB5BbUESpNiZsMRjcKO3lKLuBCyPmmOlLO9N0C5SVTGPUkQztU/ju7SVLRqUTjuyA3Auwi0NuxE6lMwcsMSiG4KQrqhOm4uwi6VGG9TWyuwlFt1XbYsYlrvtQQGg8XYb2YRlGPoQwuGNbOJsYpwzEPxoZ6m8+UvORqXfXoxGvbfxC4t9CkRZrrODlLjQ==; Received: from c-24-19-133-76.hsd1.wa.comcast.net ([24.19.133.76] helo=[192.168.1.174]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WUNc9-0002n9-AJ; Sun, 30 Mar 2014 14:50:01 -0700 Message-ID: <53389187.3090901@dancol.org> Date: Sun, 30 Mar 2014 14:49:59 -0700 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 References: <53362D5C.2070502@dancol.org> <53363260.9060207@dancol.org> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="B8Pm5rfrVuklb2or0rJQbJGkR5R3UiDFf" X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --B8Pm5rfrVuklb2or0rJQbJGkR5R3UiDFf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/30/2014 02:39 PM, Stefan Monnier wrote: >>> run post-command-hook; completion-in-region--postch is on the list of= >>> hooks to run. This function runs completion-in-region-mode--predicat= e, >>> which makes a hidden call to the subprocess; >=20 > Using the subprocess from completion-in-region--postch sounds > like a problem/bug, indeed. Why do we(I?) do that? >=20 >>> Why can't we do the completion-in-region--postch stuff in pre-command= -hook? >=20 > Because pre-command-hook would come even later (it would only disable > completion-in-region-mode at the beginning of the next command after RE= T). You're right: that's a bad solution. I was thinking we could somehow detect RET and other side-effect-ful commands, but just augmenting comint-send-input is better. >=20 >> + ;; If we're currently completing, stop. We're definitely done >> + ;; completing, and by sending the input, we might cause side effect= s >> + ;; that will confuse the code running in the completion >> + ;; post-command-hook. >> + (when completion-in-region-mode >> + (completion-in-region-mode -1)) >=20 > I see you installed it, thanks, I think it's OK. But I'd also like to > know why we contact the subprocess from completion-in-region--postch, > because that's risky. In my case, I have a JavaScript repl to which Emacs connects over a socket. Each connection gets a separate JavaScript global environment, so completion in the comint buffer has to use the same underlying socket that's connected to the buffer. Completion works by using comint redirection to send JavaScript over the socket, then waiting for a reply. completion-in-region--postch needs to use the normal completion machinery (via the predicate set up in completion-at-point) to detect whether the completion region has changed, and this machinery contacts the subprocess to find the completion candidates. Come to think of it, supplying a function instead of a simple list of strings as the completion table returned from the completion function would probably help too, since then completion-in-region--postch could inspect the first element of the returned list (the completion region start) without having to actually "force the promise" and resolve the whole list after every command. --B8Pm5rfrVuklb2or0rJQbJGkR5R3UiDFf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTOJGHAAoJEMAaIROpHW7INp8QAMUZCzK5C7D/VTkBmkpRLJ7i P2vmgxDDt3ahwYpbdXDEKKQps6IHaOS9WGsSfdK2dsNyspTjzjxh2TPiWNZhdYiG 6foe84MMUZb0XScQTF1lfkbI8jkwMFKMpOY9HwfnHNkc63/nFTGWDd8KhuUWx6Xq But307zcRg46O07YQG1CCDP0uQpc1e+ldMRWPFcvlTaJwN446lJqZIE5L6kbfLsj c+pZ7f2liSli9tgNMqA4dn+jxOwQghj4flv5LZfOejsJRxb7jGF+j3iCrZcHMm8F fCSLyfVghjjpxMoKGF7eRj5nEx57Wr2Tesdg0uI4pYobBq0ZpLFmu1GsPPRo2Fku dQfsRfiBICOAI96eAymODluY8abyJ7ibhXIVNEYXeDnflhqkf6i8jAmyeUYc2W3y 7SWzX+xh0+C//+Igv9TADQTTSE407jVlDfl3drIXhdRDoMcFOkLEScf8X+DLjsrT HkeEFirPgtBqYeo9S2S0Sf8XU+5jL8vDzFwSHppdBMnqiZu94bNHOrWI3gKIViHf ghtYPKRzPjo6UZ9UarSUzxbf3catWaMiGvQlfp5tfFY15F3e7itzO15KoUyHm9lq 9WI9qmRYugfbHvPCRuvyeNnnzwUC5cx4cj67hyjfc6iKCkUMuPlhfoemAv5sLK5a 61kJU2qWhVP7zheGEPKm =152o -----END PGP SIGNATURE----- --B8Pm5rfrVuklb2or0rJQbJGkR5R3UiDFf-- From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Mar 2014 12:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Daniel Colascione Cc: 17139@debbugs.gnu.org Received: via spool by 17139-submit@debbugs.gnu.org id=B17139.13962696167272 (code B ref 17139); Mon, 31 Mar 2014 12:41:03 +0000 Received: (at 17139) by debbugs.gnu.org; 31 Mar 2014 12:40:16 +0000 Received: from localhost ([127.0.0.1]:57665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUbVe-0001tD-TH for submit@debbugs.gnu.org; Mon, 31 Mar 2014 08:40:15 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:51449) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUbVY-0001sw-Pt for 17139@debbugs.gnu.org; Mon, 31 Mar 2014 08:40:09 -0400 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s2VCeR2Z025682; Mon, 31 Mar 2014 08:40:27 -0400 Received: by pastel.home (Postfix, from userid 20848) id 5D1F6604C6; Mon, 31 Mar 2014 08:40:04 -0400 (EDT) From: Stefan Monnier Message-ID: References: <53362D5C.2070502@dancol.org> <53363260.9060207@dancol.org> <53389187.3090901@dancol.org> Date: Mon, 31 Mar 2014 08:40:04 -0400 In-Reply-To: <53389187.3090901@dancol.org> (Daniel Colascione's message of "Sun, 30 Mar 2014 14:49:59 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4898=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4898> : inlines <664> : streams <1148397> : uri <1715862> X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > Come to think of it, supplying a function instead of a simple list of > strings as the completion table returned from the completion function > would probably help too, since then completion-in-region--postch could > inspect the first element of the returned list (the completion region > start) without having to actually "force the promise" and resolve the > whole list after every command. Exactly: completion-in-region--postch does not need to know the candidates. If you need a subprocess to get the list of candidates, then foo-at-point-function is usually not the right place/time to build this list, you should use completion-table-dynamic, completion-table-with-cache, or something like that instead. Some foo-at-point-function get away with building the list directly, but then caching it so that subsequent calls (e.g. via completion-in-region--postch) don't need to contact the subprocess again. Of course, there could be cases where the star&end positions are themselves computed by a subprocess, in which case completion-in-region--postch would have to contact the subprocess. Stefan From unknown Sat Jun 14 19:37:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Mar 2014 18:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 17139@debbugs.gnu.org Received: via spool by 17139-submit@debbugs.gnu.org id=B17139.13962900278221 (code B ref 17139); Mon, 31 Mar 2014 18:21:01 +0000 Received: (at 17139) by debbugs.gnu.org; 31 Mar 2014 18:20:27 +0000 Received: from localhost ([127.0.0.1]:58173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUgos-00028X-O7 for submit@debbugs.gnu.org; Mon, 31 Mar 2014 14:20:27 -0400 Received: from dancol.org ([96.126.100.184]:56351) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WUgoq-00028O-Go for 17139@debbugs.gnu.org; Mon, 31 Mar 2014 14:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:In-Reply-To:References:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=XgX0p/BidtPKl8VMTqlsY9G5RV2sMmk9dQ/3Ce/emqg=; b=cHlrdogTSPxu+Mz5C4XRiQ/p9dEezjFRJ0HPCE+sbLVWv0Dwb3qk+BBupAhFV4JVupfxW7cKzNt2WX6djR46GcgqwQpqJa8K6eAdlPULfeIn/MT+XSdxMlPLI+WgKcXy9j+gKTQ58C3P1xfF1mBvlUX+xuPTw0baDGaC6HkNuTrnbIYJf02Vr0nqdBFpHwi1nzTTCbB4e/i41/6jgTy5TF4lgqAXZXlDm6iQYstWqFv+wG6G1TNVbArIlSGFvaXigcyKVeKcTWyPEXv58PGNQVQUz4l3sMpH+NsZ3//FdsxLTJtDEF5Hv+MifVlkG9CFTFJpx6tvnF8YHNslGkg0JQ==; Received: from c-24-19-133-76.hsd1.wa.comcast.net ([24.19.133.76] helo=[192.168.1.50]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WUgop-0001oF-6B; Mon, 31 Mar 2014 11:20:23 -0700 Message-ID: <5339B1E5.8020900@dancol.org> Date: Mon, 31 Mar 2014 11:20:21 -0700 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 References: <53362D5C.2070502@dancol.org> <53363260.9060207@dancol.org> <53389187.3090901@dancol.org> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fIipVBP8MPBtH2m1KBFmaVNOGaoefdJN4" X-Spam-Score: -0.6 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fIipVBP8MPBtH2m1KBFmaVNOGaoefdJN4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/31/2014 05:40 AM, Stefan Monnier wrote: >> Come to think of it, supplying a function instead of a simple list of >> strings as the completion table returned from the completion function >> would probably help too, since then completion-in-region--postch could= >> inspect the first element of the returned list (the completion region >> start) without having to actually "force the promise" and resolve the >> whole list after every command. >=20 > Exactly: completion-in-region--postch does not need to know the > candidates. If you need a subprocess to get the list of candidates, > then foo-at-point-function is usually not the right place/time to build= > this list, you should use completion-table-dynamic, > completion-table-with-cache, or something like that instead. I've added some recommendations to this effect to the manual. --fIipVBP8MPBtH2m1KBFmaVNOGaoefdJN4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTObHlAAoJEMAaIROpHW7IIVcP/3AMHJK78wPG8IDj/C5SL2oV frybcL92LIfVeO2ub2r6eqlEKPb2TpLXZl8+70F2VgS1uciw69xPnmhpyzoMaI7d pattrrwhxj1q9MKXCz2q3b0H83G5M8vz+NLSxq7yxJ+SfiaU5I3fdZqNXZaYCkyz O/HqloitZZZlQRoweJAPIAeESwAQ3f1ZjhDQFI1lDEfgghSZpqRnQ9l1uqQkYy1l AN2yVRXu9vl+DL07Qp9J+BBCgt1eW4ocEsfG36fIpmlKZ7bIAFQB70Gj+YbpgAea tsX5djQXXG2jmctW9qbuAlkRvgHZooHE4KhCXUR8UEXfZybfzpb/22ccCfhTa8wO W9ZbmYj9AgsDzAt4CfCQN7hThFwmFmhCH7rDH16BUovBnR70zj00Agu5vixmq35z q6VGOTbUmbHt/jZiLNtZlD7LPGnMqweABheaxEStE8Pt0xGevcK2RTe2FopZaHsx 3DE3jkFEtbExtZ1NoXutG6c2u1oqQ+0V5OF3VDayZrqvOt8ZLaZeFmk0Iw0VQ0+C qSmT8CJNzUgHAQ8ElzMHXizEOvm7GgNETAPwlnKkZ3eFWbhuFUmt6+QAXCLux8L7 8LY8ZyWlZeWuobMergZr6T43243qiyxHBk22kpT8Kmcfgj6rScmS5+b72xGjuADi AtOLnKDUiT0LtJ60qUU0 =UPFQ -----END PGP SIGNATURE----- --fIipVBP8MPBtH2m1KBFmaVNOGaoefdJN4-- From unknown Sat Jun 14 19:37:42 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Daniel Colascione Subject: bug#17139: closed (Re: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook?) Message-ID: References: <53362D5C.2070502@dancol.org> X-Gnu-PR-Message: they-closed 17139 X-Gnu-PR-Package: emacs Reply-To: 17139@debbugs.gnu.org Date: Sat, 04 Jun 2016 22:18:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1465078682-32141-1" This is a multi-part message in MIME format... ------------=_1465078682-32141-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #17139: Race condition in complete-in-region: should we be using pre-comman= d-hook, not post-command-hook? which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 17139@debbugs.gnu.org. --=20 17139: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D17139 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1465078682-32141-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 17139-done) by debbugs.gnu.org; 4 Jun 2016 22:17:55 +0000 Received: from localhost ([127.0.0.1]:54692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9JtD-0008Lz-IO for submit@debbugs.gnu.org; Sat, 04 Jun 2016 18:17:55 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9JtC-0008Lm-SY for 17139-done@debbugs.gnu.org; Sat, 04 Jun 2016 18:17:55 -0400 Received: by mail-oi0-f67.google.com with SMTP id e80so15567009oig.1 for <17139-done@debbugs.gnu.org>; Sat, 04 Jun 2016 15:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=FRkdw3BcWRJgGxYAPuxzhMh5rOKYZzv8ZXhCQi99nL4=; b=zaTnlTmMtMMHvSxBdkndtPgHIFhmcK75udtsJXIV2/c2JxH3eZD8aGVrb2Pmc4gxda GnT7Z2Ab5an/YBMl4ynUtSSMTgtqGfstUdgSIPDdgWvBPfu7pzFccOCAPXMVPOQmedQB 92Laohsr9Ydas1akvkyIY2vuzZKZx9dy1VFDREdk/rxNYw4+4rh1XzOqSFWEIxdhuTi8 J1MA5XHjY0onaKALxKtpPOIc211+QNTy/d9oAV62hqj2a9mR5KxwKccJR3wuUQMjDUS3 1DM1Vl+276Uzh3IXaovrsSHjOD0uSokYWbjrP/G2hIZt7mG0vZSi+bUt1A1sXb0oVGhM X0Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:cc; bh=FRkdw3BcWRJgGxYAPuxzhMh5rOKYZzv8ZXhCQi99nL4=; b=mfeV1p4GSHXHDoJqfbTPqKJCnP2s1qI3rj8hFs7VP1nsOrlX6MzYlufOW7uE5G7/TH dIJSsjXR6Uj/pp8D0nK+6wnDnBm+yMYxEwGNk8/SwE3tXWE/DRnGSEUqL2r3fJcv/Txk QTMHPgfzG11taPC4KUxnPIIObalWhqEB8eEq2b05IX95xfDlu+odFgZIyyLf8UMCAQV6 mCP38h8v6iFZbvA86TqVxJqC5ylxshSzVcYzD78T8N51NEPCMhwxsBaTNHBJBQMoiKL2 x/E5KnoLNeoGiJFAblUpQDZSAs7xA68IUlVlUAyFg39v5aoEDZ+LSaGH2oxoidhhHwg+ CW3Q== X-Gm-Message-State: ALyK8tLGZWB++JLnbBS3wanHqlrPn2ssGYee6npX6WIxZZxidgLmusMGgQybCksah3dzto19yzNpjOFEzDCWPg== X-Received: by 10.202.75.80 with SMTP id y77mr5362395oia.144.1465078669449; Sat, 04 Jun 2016 15:17:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.5.168 with HTTP; Sat, 4 Jun 2016 15:17:49 -0700 (PDT) From: Noam Postavsky Date: Sat, 4 Jun 2016 18:17:49 -0400 X-Google-Sender-Auth: 3NDVhFSFqw5oNSXaLVJbROWixFs Message-ID: Subject: Re: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? To: 17139-done@debbugs.gnu.org Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 17139-done Cc: Daniel Colascione , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Closing since this seems to have been resolved. ------------=_1465078682-32141-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Mar 2014 02:18:35 +0000 Received: from localhost ([127.0.0.1]:55290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTiqw-00072c-In for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38351) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WTiqu-00072U-N3 for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTiqo-000539-38 for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqn-000535-WC for submit@debbugs.gnu.org; Fri, 28 Mar 2014 22:18:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqh-0005j7-J9 for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTiqb-00052C-4x for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:19 -0400 Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:51548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTiqa-000527-Pw for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 22:18:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=ZTmJqsy5J1CRlx0W4DsFJupJtD7rPRcJZWQsy8AB3Uk=; b=eosg6Ga7Zl+w97lKiDAmuK8gYLfPZ5nsBSxwqArUMMoqbO332HOreMT2PBpmY9GzhwwAHfBABldXmSm5B73E7W4o/7s6+/oSK4VOy4NbRk4mmJk4g73wGKLimpdeC40ytmhZUkZFkt5MiME6ul0VxWfpu6fr5hyv8H2cr7bdOi89LLbgUKGLGvDEiqo6QSKjekir5Bxhb55hrWw7fHvDZVEecbtJ0syVKv2PGLFpfryRUcyzl4mWel08l1cCDGcxhuySDl90znYt6b9xao/muhE4N3n50aXmN0uc+CrsvoBzLdKpyZkJ8DmjiKHzYtPbWiWgEPHS/Pitegp+VX7opg==; Received: from ip-64-134-226-73.public.wayport.net ([64.134.226.73] helo=[192.168.5.69]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WTiqZ-00015H-KX for bug-gnu-emacs@gnu.org; Fri, 28 Mar 2014 19:18:11 -0700 Message-ID: <53362D5C.2070502@dancol.org> Date: Fri, 28 Mar 2014 19:18:04 -0700 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: "bug-gnu-ema >> bug-emacs" Subject: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-hoo= k? --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTNi1cAAoJEMAaIROpHW7IUpYP/3Y27FKf0oI0UZAc2Q93tBtr g96Fkqb92U+VK6Ax/RGewhSVIt/EuJ8KHf+py/XZDvb1byrQx518H9t3HY0+Q7C7 5XNRBflLgwH72apXkOiasCUNA3fbDdXTWrw9+QDmE6Efqs+XSPud/ebRiAsk2NoC Cy2sgfU5PGWNV6Y7dltyb+KVC8VNd+m3Wcq7TxkFILha+uN4BXX0+qw8pIHQKvbD fYi8euKhDEN4kYYngAANEbDnbna2UbXjr1Rl7FDozsnhuWScHN85ujTJZzKXg3YW qTP1+xdCXU2rHvEAYckynKf36go9bg97x7KAk/oL1wFoOcsl6vz6mAZLZAxOFMq0 wkIUDEqIpNTwoi1C3zXa3CKXpfw54mK8rN4LexDDygQVLS9O9E7kpequgV+/rwGS Pw86KP0biV/QOLVlPMA05Xq65AVmV4aNo9+l3wlvnWCzfQGCssEGlJH8ZtCqufRb geidX7FcBPVdWvFPj5L//2hlp9edCuCdUyNnGOQzIPNv/DLGLA/Dc3FLuTrmxlGJ 0GXbhWXk02NwQW7h+SMYmpWuQ3tXmERDsyA5ytvuhCGOh5wuxzP5n5wY7rTGUJrF djfzzONHqar43KhPpntdpUAPKng+GR9ZdViOKsmHvVi/Ez+9MCKoeTRn/jKsFqgI 8K2Ka1yBSbt0K5amtY8w =qGNB -----END PGP SIGNATURE----- --2mjSHfBbEET1N1abhJvgfaxBC19gqIpnf-- ------------=_1465078682-32141-1--