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

Previous Next

Package: emacs;

Reported by: Samuel Muñoz Hidalgo <samuel.mh <at> gmail.com>

Date: Fri, 12 Nov 2021 11:57:02 UTC

Severity: normal

Tags: confirmed

To reply to this bug, email your comments to 51788 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#51788; Package emacs. (Fri, 12 Nov 2021 11:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Samuel Muñoz Hidalgo <samuel.mh <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 Nov 2021 11:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Samuel Muñoz Hidalgo <samuel.mh <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: cua + ansi-term hangs
Date: Fri, 12 Nov 2021 12:22:18 +0100
[Message part 1 (text/plain, inline)]
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.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51788; Package emacs. (Tue, 20 Sep 2022 13:23:01 GMT) Full text and rfc822 format available.

Message #8 received at 51788 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Samuel Muñoz Hidalgo <samuel.mh <at> gmail.com>
Cc: 51788 <at> debbugs.gnu.org
Subject: Re: bug#51788: cua + ansi-term hangs
Date: Tue, 20 Sep 2022 15:22:32 +0200
Samuel Muñoz Hidalgo <samuel.mh <at> gmail.com> 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 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 nil 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?




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 20 Sep 2022 13:23:02 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 271 days ago.

Previous Next


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