GNU bug report logs - #51788
cua + ansi-term hangs

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Samuel Muñoz Hidalgo <samuel.mh@HIDDEN>; Keywords: confirmed; dated Fri, 12 Nov 2021 11:57:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 51788 <at> debbugs.gnu.org:


Received: (at 51788) by debbugs.gnu.org; 20 Sep 2022 13:22:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 20 09:22:44 2022
Received: from localhost ([127.0.0.1]:56595 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oadD2-0005yf-IW
	for submit <at> debbugs.gnu.org; Tue, 20 Sep 2022 09:22:44 -0400
Received: from quimby.gnus.org ([95.216.78.240]:46296)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oadD0-0005yO-Kc
 for 51788 <at> debbugs.gnu.org; Tue, 20 Sep 2022 09:22:43 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=+H3CJiX0SF4253ezfy2WjbhYaYu9ImM3eOhrewpM+0s=; b=TtskfoqLgq5hjHez+5BTJfznMB
 QiH3K4QEi+OmiUwDbZoqU40Ya6O0o70JxIS93+u4W7lwFMf/Nrp+JVGr+ziayqyZaL6Yf/f2Yuc2R
 wCl/XMt7n/mG+/B1z6T1h19JqQZr1y85lfl3sWsDTWZ2N3wsi7MXJx232dQtBdYmaQYo=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oadCr-0002ME-Nj; Tue, 20 Sep 2022 15:22:35 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Samuel =?utf-8?Q?Mu=C3=B1oz?= Hidalgo <samuel.mh@HIDDEN>
Subject: Re: bug#51788: cua + ansi-term hangs
In-Reply-To: <CA+kUYON-PNyQ1aTxR1=gRU_WTcPf41-eWHS-Cd3FXtK6SLtVpA@HIDDEN>
 ("Samuel =?utf-8?Q?Mu=C3=B1oz?= Hidalgo"'s message of "Fri, 12 Nov 2021
 12:22:18 +0100")
References: <CA+kUYON-PNyQ1aTxR1=gRU_WTcPf41-eWHS-Cd3FXtK6SLtVpA@HIDDEN>
X-Now-Playing: Alasdair Roberts og =?utf-8?Q?V=C3=B6lvur's?= _The Old Fabled
 River_: "Orison of Unison"
Date: Tue, 20 Sep 2022 15:22:32 +0200
Message-ID: <87tu52faef.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 
 Content preview:  Samuel Muñoz Hidalgo <samuel.mh@HIDDEN> writes: > 1- Select
    a text in a buffer and use the keybind F2 instead of calling the function
    > manually. It opens a terminal with the selected word pasted in it. > 3-
    Type C-c or (C-x) and emacs freezes with [...] 
 
 Content analysis details:   (-2.9 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51788
Cc: 51788 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Samuel Mu=C3=B1oz Hidalgo <samuel.mh@HIDDEN> writes:

> 1- Select a text in a buffer and use the keybind F2 instead of calling th=
e function
> manually. It opens a terminal with the selected word pasted in it.
> 3- Type C-c or (C-x) and emacs freezes with a 100% CPU usage in a single =
core.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I can reproduce this in Emacs 29.  Setting debug-on-quit and hitting
`C-g' give me the following backtrace:

Debugger entered--Lisp error: (quit)
  timer--activate([t 25385 48685 328606 nil cua--prefix-override-timeout ni=
l nil 450000 nil] nil nil nil)
  timer-activate([t 25385 48685 328606 nil cua--prefix-override-timeout nil=
 nil 450000 nil])
  run-at-time(0.2 nil cua--prefix-override-timeout)
  apply(run-at-time 0.2 nil cua--prefix-override-timeout nil)
  run-with-timer(0.2 nil cua--prefix-override-timeout)
  cua--prefix-override-replay(0)
  cua-copy-handler()
  funcall-interactively(cua-copy-handler)
  call-interactively(cua-copy-handler nil nil)

I'm wholly unfamiliar with cua-mode, though.  Does anybody else know
what could be happening here?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#51788; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Nov 2021 11:56:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 12 06:56:44 2021
Received: from localhost ([127.0.0.1]:43606 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mlVAf-0003ku-UG
	for submit <at> debbugs.gnu.org; Fri, 12 Nov 2021 06:56:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:37838)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <samuel.mh@HIDDEN>) id 1mlUdd-0002jJ-BP
 for submit <at> debbugs.gnu.org; Fri, 12 Nov 2021 06:22:36 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40486)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <samuel.mh@HIDDEN>)
 id 1mlUdd-0006v5-6A
 for bug-gnu-emacs@HIDDEN; Fri, 12 Nov 2021 06:22:33 -0500
Received: from [2a00:1450:4864:20::533] (port=34394
 helo=mail-ed1-x533.google.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <samuel.mh@HIDDEN>)
 id 1mlUdb-0008BG-57
 for bug-gnu-emacs@HIDDEN; Fri, 12 Nov 2021 06:22:32 -0500
Received: by mail-ed1-x533.google.com with SMTP id x15so36376552edv.1
 for <bug-gnu-emacs@HIDDEN>; Fri, 12 Nov 2021 03:22:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:from:date:message-id:subject:to;
 bh=0EqZ4seii9HA1VmmZj/6XBybvgBgb8h8I7a/Djsr7yg=;
 b=mSjsc9124zRlhNQkTzvPc8H/jdi5B8GD2kEwIDFiwHFXRZIrgxh3Snf4xhHo/uPe9p
 uYrZ0s+HZxS4rwS8+dc7ZoyaQijrU70lxcp9Qs6KqW0Y3znq5llNuXiht9qCroRLNfe8
 MMngMYWDFDd5Gy/+2/yoNiXoNb5/T4dNjBPzGrLhWmJQnYTkCVKWnIOWMD5rDl2c/svG
 SyoPUh2Q9dULulMNiYbcJFwNl71my02479Nr2nl1NnFwCy3dF0A6eu9vP6uM1Mm6mYwl
 nDYFyWa4T+OpohxgK7AcwKx9amCWl5CCvVMsqL4kjppBe0o4L27AtUq3Q3T6FnJSk02d
 mOBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=0EqZ4seii9HA1VmmZj/6XBybvgBgb8h8I7a/Djsr7yg=;
 b=xme84JlkMQp3GFMnA2T817texbdoMY4FBcHyQY/9Y1Cae2raCnD6MUyVgO93TMY0tX
 Mi70SEEOu3HvU/SF62cqUjKtzv5aRI9PDzqYeIkjMPxMq+eFObRDwBvHWcNnh6LXqOjf
 Vz50sIalwkdX4z66FmM99bV5m9yG4gxfHXx9+spl8AmTdVOanQp2c8gZXbPvXHOTGi4E
 d7H4t5hE8je/hjsjecWXd3UwtKJyFd6Wj5yjZ9vZ/Hxi+nurxj668j1fOGmnuIHUinDT
 QxEeZDvLKbvc8wft5nGJxkEc3jbOrCLtTkzTqE5Mg+x+vKwWR53VWYnYAr+3XlaMIFQM
 y5lw==
X-Gm-Message-State: AOAM532tdnhORLO6VmVNzADphJGa9Eo4pX4eMADix9MVcAFZonmJRihL
 w0zEs3j4kq737w4rqVNZBdNg7raObujpxTK2fQz9vIqPcxU=
X-Google-Smtp-Source: ABdhPJyJI1brsAho6xA4KvdIMBKJI6HNxjPTWo3wHnypwVQWaCvfLtwi0Zgs+2cXDgQ8rblA9knMA4n4Vj4r2Eze/lU=
X-Received: by 2002:a17:907:86a1:: with SMTP id
 qa33mr18887144ejc.142.1636716148963; 
 Fri, 12 Nov 2021 03:22:28 -0800 (PST)
MIME-Version: 1.0
From: =?UTF-8?Q?Samuel_Mu=C3=B1oz_Hidalgo?= <samuel.mh@HIDDEN>
Date: Fri, 12 Nov 2021 12:22:18 +0100
Message-ID: <CA+kUYON-PNyQ1aTxR1=gRU_WTcPf41-eWHS-Cd3FXtK6SLtVpA@HIDDEN>
Subject: cua + ansi-term hangs
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000a83ebf05d095acb8"
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::533
 (failed)
Received-SPF: pass client-ip=2a00:1450:4864:20::533;
 envelope-from=samuel.mh@HIDDEN; helo=mail-ed1-x533.google.com
X-Spam_score_int: -12
X-Spam_score: -1.3
X-Spam_bar: -
X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001,
 RDNS_NONE=0.793, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 12 Nov 2021 06:56:41 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--000000000000a83ebf05d095acb8
Content-Type: text/plain; charset="UTF-8"

Hello,

I've tried to implement a small utility function in elisp and I end up with
emacs hanged whenever certain conditions are met.

The utility has to do with sending the selected text to a term buffer and
when in the term buffer if C-c  (or C-x) is pressed, it hangs.

I 've traced the behavior and my guess it that is has to do with cua-mode.


EMACS VERSION:
I've been able to replicate the behaviour in :
- GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo
version 1.16.0)
- GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of
2020-03-26, modified by Debian


CONTEXT:

1- Open an empty emacs instance:
```
/usr/bin/emacs -q
```

2- Paste this code in a buffer (*scratch*)
```
(cua-mode t)

(defun terminal-send-selection()
  (interactive)
  (call-interactively #'kill-ring-save)
  (ansi-term "/usr/bin/bash" "test")
  (term-paste)
  )

(global-set-key [f2] 'terminal-send-selection)
```

3- Eval the buffer with the code `eval-buffer`


CASE 1 (OK):
1- Select a text in a buffer and 'M-x' `terminal-send-selection`. It opens
a terminal with the selected text pasted in it.
3- Type C-c, then prefix key is activated.
4- Type C-c again and works as expected, the pasted text is executed in
bash.

CASE 2 (PROBLEM):
1- Select a text in a buffer and use the keybind F2 instead of calling the
function manually. It opens a terminal with the selected word pasted in it.
3- Type C-c or (C-x) and emacs freezes with a 100% CPU usage in a single
core.
4- Then on a external shell:
```
kill -USR2 `pidof emacs`
```
And I get in the minibuffer.
```
Error in pre-command-hook (term-set-goto-process-mark): (quit)
```
Emacs is still hanged.
5- Repeat the command in the external shell.
```
kill -USR2 `pidof emacs`
```
And I get in *Backtrace*
```
Debugger entered--Lisp error: (quit)
```
The editor is not hanged anymore. But the behaviour is undesired.


CASE 3 (OK):
1- Don't activate cua-mode. Redo al the process but without copying the
line`(cua-mode t)`.
2- Then case 2 work as expected.


OTHER APPROACHES:
Instead of using the function "term-paste" I have also tried with.

1 - Using the function "comint-send-string".
2 - Pasting directly the test in the ansi-term buffer.

With the same results.


Why does the CASE 2 happens?
As the code is so simple I think this has to be a bug. Any help or insights
are welcome.

--000000000000a83ebf05d095acb8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello,<br><br>I&#39;ve tried to implement a small utility =
function in elisp and I end up with emacs hanged whenever certain condition=
s are met.<br><br>The utility has to do with sending the selected text to a=
 term buffer and when in the term buffer if C-c=C2=A0 (or C-x) is pressed, =
it hangs.<br><br>I &#39;ve traced the behavior and my guess it that is has =
to do with cua-mode.<br><br><br>EMACS VERSION:<br>I&#39;ve been able to rep=
licate the behaviour in :<br>- GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu=
, GTK+ Version 3.24.20, cairo version 1.16.0)<br>- GNU Emacs 26.3 (build 2,=
 x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debi=
an<br><br><br>CONTEXT:<br><br>1- Open an empty emacs instance:<br>```<br>/u=
sr/bin/emacs -q<br>```<br><br>2- Paste this code in a buffer (*scratch*)<br=
>```<br>(cua-mode t)<br><br>(defun terminal-send-selection()<br>=C2=A0 (int=
eractive)<br>=C2=A0 (call-interactively #&#39;kill-ring-save)<br>=C2=A0 (an=
si-term &quot;/usr/bin/bash&quot; &quot;test&quot;)<br>=C2=A0 (term-paste)<=
br>=C2=A0 )<br><br>(global-set-key [f2] &#39;terminal-send-selection)<br>``=
`<br><br>3- Eval the buffer with the code `eval-buffer`<br><br><br>CASE 1 (=
OK):<br>1- Select a text in a buffer and &#39;M-x&#39; `terminal-send-selec=
tion`. It opens a terminal with the selected text pasted in it.<br>3- Type =
C-c, then prefix key is activated.<br>4- Type C-c again and works as expect=
ed, the pasted text is executed in bash.<br><br>CASE 2 (PROBLEM):<br>1- Sel=
ect a text in a buffer and use the keybind F2 instead of calling the functi=
on manually. It opens a terminal with the selected word pasted in it.<br>3-=
 Type C-c or (C-x) and emacs freezes with a 100% CPU usage in a single core=
.<br>4- Then on a external shell:<br>```<br>kill -USR2 `pidof emacs`<br>```=
<br>And I get in the minibuffer.<br>```<br>Error in pre-command-hook (term-=
set-goto-process-mark): (quit)<br>```<br>Emacs is still hanged.<br>5- Repea=
t the command in the external shell.<br>```<br>kill -USR2 `pidof emacs`<br>=
```<br>And I get in *Backtrace*<br>```<br>Debugger entered--Lisp error: (qu=
it)<br>```<br>The editor is not hanged anymore. But the behaviour is undesi=
red.<br><br><br>CASE 3 (OK):<br>1- Don&#39;t activate cua-mode. Redo al the=
 process but without copying the line`(cua-mode t)`. <br>2- Then case 2 wor=
k as expected.<br><br><br>OTHER APPROACHES:<br>Instead of using the functio=
n &quot;term-paste&quot; I have also tried with.<br><br>1 - Using the funct=
ion &quot;comint-send-string&quot;.<br>2 - Pasting directly the test in the=
 ansi-term buffer.<br><br>With the same results.<br><br><br>Why does the CA=
SE 2 happens? <br>As the code is so simple I think this has to be a bug. An=
y help or insights are welcome.<br></div>

--000000000000a83ebf05d095acb8--




Acknowledgement sent to Samuel Muñoz Hidalgo <samuel.mh@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#51788; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 20 Sep 2022 13:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.