syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

Constant freezes in evil-delete-char (using a minimal configuration on OpenBSD) #13178

Closed bforte closed 1 year ago

bforte commented 4 years ago

Description

Emacs froze on various occasions (I recall deleting two lines with d2j and using x to cut the current character) to the point where I had to kill it by external means (kill -15).

I'm new to Emacs, so I don't know how to fix this myself but did my best to track the freezes. Their origin seems to come from evil-delete/evil-delete-char. The behaviour is fairly reproducible by using x in any file, it makes Spacemacs barely usable.

Reproduction guide

  1. rm -rf ~/.emacs.d && git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
  2. Start Emacs
  3. Use a minimal configuration:
    • What is your preferred editing style? -> choose vim
    • What distribution of spacemacs would you like to start with? -> choose spacemacs-base (same with spacemacs, just doing this to reduce the potential sources of the bug)
    • What type of completion framework do you want? -> choose None (again, this doesn't seem to matter.. I initially picked ivy here)
  4. Success.. The only warning in *spacemacs*: Cannot find any of the specified fonts (Source Code Pro)! Font settings may notbe correct. (behaviour persists when using an installed font)

These steps don't always, but with high "success" rate, reproduce the error:

  1. create new file :e bug.txt and:
    • enter some characters (a in the following backtraces, doesn't matter though)
  2. use x

Observed behaviour:

  1. Emacs freezes, C-g doesn't work, not even the window-manager can close it
  2. Either use xkill and clean up or use kill -15 work to kill it

Expected behaviour:

The behaviour of evil-delete-char: cut the character and put in ", at least please don't freeze. It makes Spacemacs unusable.

System info

$ uname -a
OpenBSD host.name 6.6 GENERIC.MP#3 amd64
$ emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Backtrace

Using kill -SIGUSR2 I was able to get some backtraces. A freeze with x produced (it always looks the same):

Debugger entered--Lisp error: (quit)
  x-get-selection-internal(CLIPBOARD STRING nil nil)
  #f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>)(CLIPBOARD STRING)
  apply(#f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>) (CLIPBOARD STRING))
  gui-backend-get-selection(CLIPBOARD STRING)
  gui-get-selection(CLIPBOARD STRING)
  gui--selection-value-internal(CLIPBOARD)
  gui-selection-value()
  kill-new("a")
  evil-yank-characters(55 56 nil nil)
  evil-yank(55 56 exclusive nil nil)
  evil-delete(55 56 exclusive nil)
  evil-delete-char(55 56 exclusive nil)
  funcall-interactively(evil-delete-char 55 56 exclusive nil)
  call-interactively(evil-delete-char nil nil)
  command-execute(evil-delete-char)

To copy it here I marked it all with vgg and yanked it which produced another freeze:

Debugger entered--entering a function:
* undo-tree-post-gc()
  #f(compiled-function () #<bytecode 0xb241f0ed>)()
  evil-yank(1 809 line nil nil)
  funcall-interactively(evil-yank 1 809 line nil nil)
  call-interactively(evil-yank nil nil)
  command-execute(evil-yank)
  recursive-edit()
  debug(error (quit))
  x-get-selection-internal(CLIPBOARD STRING nil nil)
  #f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>)(CLIPBOARD STRING)
  apply(#f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>) (CLIPBOARD STRING))
  gui-backend-get-selection(CLIPBOARD STRING)
  gui-get-selection(CLIPBOARD STRING)
  gui--selection-value-internal(CLIPBOARD)
  gui-selection-value()
  kill-new("a")
  evil-yank-characters(55 56 nil nil)
  evil-yank(55 56 exclusive nil nil)
  evil-delete(55 56 exclusive nil)
  evil-delete-char(55 56 exclusive nil)
  funcall-interactively(evil-delete-char 55 56 exclusive nil)
  call-interactively(evil-delete-char nil nil)
  command-execute(evil-delete)

Huh, another one by accident: Re-started Emacs and ESC k:

Debugger entered--Lisp error: (quit)
  x-get-selection-internal(CLIPBOARD STRING nil nil)
  #f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>)(CLIPBOARD STRING)
  apply(#f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>) (CLIPBOARD STRING))
  gui-backend-get-selection(CLIPBOARD STRING)
  gui-get-selection(CLIPBOARD STRING)
  gui--selection-value-internal(CLIPBOARD)
  gui-selection-value()
  kill-new("  be correct.")
  copy-region-as-kill(894 907 nil)
  kill-region(894 907)
  kill-sentence(1)
  funcall-interactively(kill-sentence 1)
  call-interactively(kill-sentence nil nil)
  command-execute(kill-sentence)

I could not repro it with using Emacs+evil only, using the following init.el so it does not seem like it is a problem of Emacs.

;; load melpa package manager
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;; update local package index
(unless package-archive-contents (package-refresh-contents))

;; install evil
(setq package-list '(evil evil-leader))
(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

;; configure evil
(require 'evil)
(evil-mode t)

(require 'evil-leader)
(global-evil-leader-mode)
(evil-leader/set-leader ",")
(evil-leader/set-key
  "b" 'switch-to-buffer
  "w" 'save-buffer)
bforte commented 4 years ago

Checked on dev branch (ie. git clone -b develop https://github.com/syl20bnr/spacemacs ~/.emacs.d):, and the behaviour seems to have changed.

Here's another backlog from the development branch when attempting to use y on some marked section:

Debugger entered--entering a function:
* #f(compiled-function () #<bytecode 0xbda712f5>)()
  evil-yank(1 1506 line nil nil)
  funcall-interactively(evil-yank 1 1506 line nil nil)
  call-interactively(evil-yank nil nil)
  command-execute(evil-yank)
  recursive-edit()
  debug(lambda)
* evil--jump-hook()
  recursive-edit()
  debug(lambda)
* symbol-overlay-refresh(1 5 0)
  x-get-selection-internal(CLIPBOARD STRING nil nil)
  #f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>)(CLIPBOARD STRING)
  apply(#f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x35efd1>) (CLIPBOARD STRING))
  gui-backend-get-selection(CLIPBOARD STRING)
  gui-get-selection(CLIPBOARD STRING)
  gui--selection-value-internal(CLIPBOARD)
  gui-selection-value()
  kill-new(#("<snip>" 0 4 (fontified t yank-handler (evil-yank-line-handler nil t)) 4 5 (face font-lock-comment-delimiter-face fontified t yank-handler (evil-yank-line-handler nil t)) 5 6 (face font-lock-comment-delimiter-face fontified t yank-handler (evil-yank-line-handler nil t)) 6 15 (face font-lock-comment-face fontified t yank-handler (evil-yank-line-handler nil t)) 15 16 (face font-lock-comment-face fontified t yank-handler (evil-yank-line-handler nil t)) 16 17 (face font-lock-comment-face fontified t yank-handler (evil-yank-line-handler nil t)) 17 31 (face font-lock-comment-face fontified t yank-handler (evil-yank-line-handler nil t))))
  evil-yank-lines(990 1021 nil nil)
  evil-yank(990 1021 line nil nil)
  evil-delete(990 1021 line nil nil)
  funcall-interactively(evil-delete 990 1021 line nil nil)
  call-interactively(evil-delete nil nil)
  command-execute(evil-delete)
st-j commented 4 years ago

I encountered the same problem on my Linux machine today:

Using any of the evil cut/yank commands (x, dd, y) in a text file causes emacs to freeze every time, the backtrace produced with kill -SIGUSR2 looks extremely similar to bforte's backtrace above:

   * symbol-overlay-refresh(1 5 0)
     x-get-selection-internal(CLIPBOARD UTF8_STRING nil nil)
     #f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x534949>)(CLIPBOARD UTF8_STRING)
     apply(#f(compiled-function (selection-symbol target-type &optional time-stamp terminal) #<bytecode 0x534949>) (CLIPBOARD UTF8_STRING))
     gui-backend-get-selection(CLIPBOARD UTF8_STRING)
     gui-get-selection(CLIPBOARD UTF8_STRING)
     gui--selection-value-internal(CLIPBOARD)
     gui-selection-value()
     kill-new(#("fdfd\n" 0 5 (fontified t wrap-prefix "" yank-handler (evil-yank-line-handler nil t))))
     evil-yank-lines(126 131 nil nil)
     evil-yank(126 131 line nil nil)
     evil-delete(126 131 line nil nil)
     funcall-interactively(evil-delete 126 131 line nil nil)
     call-interactively(evil-delete nil nil)
     command-execute(evil-delete)

I don't know what causes the error, but have made an interesting observation: while the above freezes occured, I had a Fedora 31 guest running in KVM (with virt-manager, in case that matters). After I shut down the VM, deleting/yanking started to work as expected in emacs.

The problem did not reappear when booting the VM again, so I unfortunately cannot reproduce the strange bug at the moment.

bforte commented 4 years ago

The bug seems to occur whenever the clipboard (XA_CLIPBOARD) is empty. If you have something in the clipboard the bug doesn't appear.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

overchu commented 3 years ago

I have the same problem since months. But it is only occuring from time to time. It seems to be a clipboard related issue since the pass password manager is also affected. Same as emacs pass hangs when it is supposed to write a password to the clipboard. All other programs work without issues. Also pash a more simple pass replacement is working while pass and emacs are affected. I will try to find what pass and emacs or spacemacs have in common regarding the clipboard.

overchu commented 3 years ago

grafik

Sorry can not copy and paste out of emacs due to the nature of the bug. So here is a screenshot.

overchu commented 3 years ago

pass copies to XA_CLIPBOARD while pash copies to the default which is XA_PRIMARY.

lebensterben commented 3 years ago

looks like upstream bug

overchu commented 3 years ago

Oh, and I am on the develop branch and the bug persists since at least four month maybe longer.

lebensterben commented 3 years ago

definitely something wrong with clipboard. do you use bsd or Linux? x11 or Wayland?

overchu commented 3 years ago

Thanks for reaching out.

I use Wayland on Linux (Fedora 34) Gnome 3

lebensterben commented 3 years ago

I suggest to post this finding to Emacs Dev mail-list. They should have better idea of what's going on.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!