1

I've spent a full working day trying to somehow resolve this, no luck, so I'm turning to this place hoping for help.

Recently I started experiencing freeze of something like up to 10 seconds when quitting Emacs. Windows 10, Emacs 26.2. Running daemon.

I've narrowed the freeze issue down to these two modes: 1) desktop-save-mode 2) back-button-mode

As soon as I disable these two modes in .emacs, emacs shuts down instantly.

I can toggle debug on quit and C-g out of kill-emacs freezing, and see Backtrace but either I don't understand how to read that or something else, I can't figure out the issue from the Backtrace (below).

I tried running without daemon, tried uninstalling lately installed packages to see if it changes anything, went through a number of possible solutions I found online, but to no avail.

These two modes are doing something in background that I just can't figure out what is happening there.

Also I don't have a large number of open buffers (really, max 10 at the same time maybe).

Will appreciate any ideas, advice, what else I could try to identify and fix the issue.

Thanks a lot in advance!

BACKTRACE:
Debugger entered--Lisp error: (quit)
  eieio-override-prin1(137379)
  #f(compiled-function (key val) #<bytecode 0x100257159>)("CJK IDEOGRAPH-218A3" 137379)
  maphash(#f(compiled-function (key val) #<bytecode 0x100257159>) #<hash-table equal 125035/125094 0x364f105>)
  eieio-override-prin1(#<hash-table equal 125035/125094 0x1002c256d>)
  #f(compiled-function (this &optional comment) "Write object THIS out to the current stream.\nThis writes out the vector version of this object.  Complex and recursive\nobject are discouraged from being written.\n  If optional COMMENT is non-nil, include comments when outputting\nthis object." #<bytecode 0x1002d6f71>)(#<pcache-entry pcache-entry>)
  apply(#f(compiled-function (this &optional comment) "Write object THIS out to the current stream.\nThis writes out the vector version of this object.  Complex and recursive\nobject are discouraged from being written.\n  If optional COMMENT is non-nil, include comments when outputting\nthis object." #<bytecode 0x1002d6f71>) #<pcache-entry pcache-entry> nil)
  object-write(#<pcache-entry pcache-entry>)
  eieio-override-prin1(#<pcache-entry pcache-entry>)
  #f(compiled-function (key val) #<bytecode 0x364e761>)(names-hash-e:26\.1-l:0\.8\.4 #<pcache-entry pcache-entry>)
  maphash(#f(compiled-function (key val) #<bytecode 0x364e761>) #<hash-table eql 2/65 0x364e725>)
  eieio-override-prin1(#<hash-table eql 2/65 0x1002d4a55>)
  #f(compiled-function (this &optional comment) "Write object THIS out to the current stream.\nThis writes out the vector version of this object.  Complex and recursive\nobject are discouraged from being written.\n  If optional COMMENT is non-nil, include comments when outputting\nthis object." #<bytecode 0x1002d6f71>)(#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  apply(#f(compiled-function (this &optional comment) "Write object THIS out to the current stream.\nThis writes out the vector version of this object.  Complex and recursive\nobject are discouraged from being written.\n  If optional COMMENT is non-nil, include comments when outputting\nthis object." #<bytecode 0x1002d6f71>) (#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT"))
  #f(compiled-function (&rest cnm-args) #<bytecode 0x364e701>)(#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  #f(compiled-function (cl--cnm this &optional comment) "Write persistent object THIS out to the current stream.\nOptional argument COMMENT is a header line comment." #<bytecode 0x2754c61>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x364e701>) #<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  apply(#f(compiled-function (cl--cnm this &optional comment) "Write persistent object THIS out to the current stream.\nOptional argument COMMENT is a header line comment." #<bytecode 0x2754c61>) #f(compiled-function (&rest cnm-args) #<bytecode 0x364e701>) (#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT"))
  #f(compiled-function (&rest args) #<bytecode 0x364e6e5>)(#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  apply(#f(compiled-function (&rest args) #<bytecode 0x364e6e5>) #<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  object-write(#<pcache-repository ucs-utils> ";; EIEIO PERSISTENT OBJECT")
  #f(compiled-function (this &optional file) "Save persistent object THIS to disk.\nOptional argument FILE overrides the file name specified in the object\ninstance." #<bytecode 0x2754c95>)(#<pcache-repository ucs-utils>)
  apply(#f(compiled-function (this &optional file) "Save persistent object THIS to disk.\nOptional argument FILE overrides the file name specified in the object\ninstance." #<bytecode 0x2754c95>) #<pcache-repository ucs-utils> nil)
  eieio-persistent-save(#<pcache-repository ucs-utils>)
  #f(compiled-function (cache &optional force) #<bytecode 0x278e6d5>)(#<pcache-repository ucs-utils> t)
  apply(#f(compiled-function (cache &optional force) #<bytecode 0x278e6d5>) (#<pcache-repository ucs-utils> t))
  #f(compiled-function (cl-cnm cache &optional force) #<bytecode 0x27ac411>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x364e619>) #<pcache-repository ucs-utils> t)
  apply(#f(compiled-function (cl-cnm cache &optional force) #<bytecode 0x27ac411>) #f(compiled-function (&rest cnm-args) #<bytecode 0x364e619>) (#<pcache-repository ucs-utils> t))
  #f(compiled-function (&rest args) #<bytecode 0x364e5a9>)(#<pcache-repository ucs-utils> t)
  apply(#f(compiled-function (&rest args) #<bytecode 0x364e5a9>) #<pcache-repository ucs-utils> t)
  pcache-save(#<pcache-repository ucs-utils> t)
  #f(compiled-function (k v) #<bytecode 0x27ab3c9>)("ucs-utils" #<pcache-repository ucs-utils>)
  maphash(#f(compiled-function (k v) #<bytecode 0x27ab3c9>) #<hash-table equal 1/65 0x2795d95>)
  pcache-kill-emacs-hook()
  kill-emacs(nil)
  funcall-interactively(kill-emacs nil)
  call-interactively(kill-emacs record nil)
  command-execute(kill-emacs record)
  #f(compiled-function (cmd) #<bytecode 0x3709c0d>)("kill-emacs")
  ivy-call()
  ivy-read("M-x " ("toggle-debug-on-quit" "customize-group" "version" "back-button-mode" "desktop-save-mode" "save-buffers-kill-emacs" "renamer" "customize-face" "copath" "ivy-recentf" "list-packages" "replace-regexp" "eval-region" "customize-variable" "json-maker-crm" "linum-mode" "org-insert-link" "js2-mode" "customize" "server-start" "org-mode" "describe-function" "undo-tree-visualize" "org-agenda" "company-tide" "company-box-mode" "tide-restart-server" "check-parens" "kolor" "company-manual-begin" "tide-mode" "comment-region" "package-delete" "display-line-numbers-mode" "delfi" "describe-face" "delete-duplicate-lines" "upcase-region" "hl-line-mode" "fill-paragraph" "setup-tide-mode" "xmlform" "menu-bar-mode" "org-do-demote" "tool-bar-mode" "line-number-mode" "set-mark-command" "yas-describe-tables" "yas-expand-from-trigger-key" "ibuffer-do-shell-command-file" ...) :predicate nil :require-match t :history counsel-M-x-history :action #f(compiled-function (cmd) #<bytecode 0x3709c0d>) :sort nil :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)
  • 1
    A long time ago, I commented out (add-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) in the pcache.el library that was on my computer and re-byte-compiled. I don't remember whether I had a problem, or whether I just was annoyed at so many things on my kill-emacs-hook. You will need to figure out whether you actually need to save that stuff. If you don't, then you can (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) -- however keep in mind, that you must unload it after the pcache library loads it.... See line 232: github.com/sigma/pcache/blob/master/pcache.el – lawlist Jul 31 at 2:12
  • Thank you so much for the idea @lawlist! You know, what I figured out is that back-button-mode was doing a lot of something that I don't understand or know how to "dig into", in combination with desktop-save-mode. – Lauris Jul 31 at 2:54
  • 1
    Your error message states that you call kill-emacs, which triggers a call to the pcache-kill-emacs-hook .... According to the comments at the outset of back-button.el, it relies upon pcache ...: raw.githubusercontent.com/rolandwalker/back-button/master/… ... Package-Requires: ((nav-flash "1.0.0") (smartrep "0.0.3") (ucs-utils "0.7.2") (list-utils "0.4.2") (persistent-soft "0.8.8") (pcache "0.2.3")) – lawlist Jul 31 at 3:01
  • Thank you so much for the idea @lawlist! You know, what I figured out is that back-button-mode was doing a lot of something that I don't understand or know how to "dig into", in combination with desktop-save-mode. What I did was by bisecting .emacs I found out that as long as I only have desktop-save-mode, things work fine. As soon as I enable back-button-mode, on exiting emacs it started doing something that was spiking CPU to 100% and spinning for even more than initially - at times for half a minute. – Lauris Jul 31 at 3:06
  • What happened then was that even if I removed back-button-mode from .emacs and only left desktop-save-mode, it was still freezing and spiking CPU. Then I could solve by desktop-clear and as long as I didn't enable back-button-mode, everything worked fine, emacs was shutting down instantly. So I replaced back-button-mode with this: melpa.org/#/backward-forward. This package kind of does the same except for option to navigate just within the buffer as back-button-mode does, backward-forward does that with global mark ring, i.e. jumps also between buffers. – Lauris Jul 31 at 3:06
1

So at the end I used the idea proposed by @lawlist: I just put (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) at the end of my .emacs. I'm not sure what was meant by "keep in mind, that you must unload it after the pcache library loads it" as I'm not that well versed in emacs/lisp. However what I was looking for is achieved even if this solution might not be technically correct: I can now navigate backward/forward within one buffer and emacs is shutting down instantly which is what was necessary. Awesome!

  • (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) will serve to remove the function pcache-kill-emacs-hook from the kill-emacs-hook only if the function was previously added thereto. If, for example, we called (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) before the pcache.el library had been loaded, then our attempt would fail because the function had not yet been added to the hook .... Thus, adding (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) to the tail end of the .emacs file is sufficient. – lawlist Jul 31 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.