Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debugging emacs freezing in adoc-mode

Tags:

emacs

elisp

I work a lot with Asciidoc in emacs (adoc-mode). I believe it has a bug that occurs when editing inlined source code. What happens is emacs freezes, CPU consumption goes to 100%. I can reproduce this behaviour easily.

How do I actually establish what script is causing emacs to hang like that?? And preferably produce a backtrace?

Since emacs freezes while typing within the buffer, rather than after executing a command, stuff like toggle-debug-on-quit or debug-on-entry are useless.

I suppose I could mark every single defun in adoc-mode.el with printfs, but I'm hoping there's an easier way :)

EDIT: So, I ended up grepping my ~/.emacs.d/lisp for ALL defuns and trace-function each one. I was able to narrow down the problem and created a small test case.

These 3 files are required:

$ find /home/victor/.emacs.d/
/home/victor/.emacs.d/
/home/victor/.emacs.d/lisp
/home/victor/.emacs.d/lisp/doc-mode.el
/home/victor/.emacs.d/lisp/adoc-mode.el
/home/victor/.emacs.d/lisp/markup-faces.el

My .emacs:

$ cat .emacs
(setq inhibit-startup-message t)
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'adoc-mode)
(switch-to-buffer (find-file "test.doc"))
(adoc-mode)
(goto-char 29)
(delete-backward-char 5)
;; now (adoc-kwf-attriblist) is in endless loop!!

And the testcase is (word "shell" is deleted by elisp):

$ cat test.doc 
blah blah blah
[source,shell]
foo
bar

Now, run emacs and it will hang in (adoc-kwf-attriblist). I don't know much about emacs programming, but seems this thing does not eventually move the point to end position.

 (goto-char (or (text-property-not-all (point) end 'adoc-attribute-list nil)
             end))
like image 543
revolt Avatar asked Feb 14 '14 19:02

revolt


1 Answers

debug-on-entry might help, if you can identify a function in the sequence that reaches the looper.

Have you tried "apropos" "debug"?

Not sure about debug-on-signal or debug-on-quit. If using Unix "kill" or Windows Task Manager "End Task" sends a signal to emacs, you might intercept it with debug-on-signal.

And search for "debug loop" at https://groups.google.com/forum/#!forum/gnu.emacs.help

Also, you could compile some functins in adoc-mode.el "debug" with edebug-defun.

(I hope I haven't fuddled this topic. I'm new here, and not familiar with "Answer" vs "Comment.)

like image 105
BobD Avatar answered Oct 17 '22 19:10

BobD