I use org-mode quite a lot and of late I have noticed one of my larger org-mode files has caused Emacs to throw this error:

Re-entering top level after C stack overflow

I tried debugging using the usual debugging mechanisms, including debugging a single function [1] but I could not get any additional information on the problem. Note also that I used the file for a very long time without seeing any problems, and I have much larger org-mode files which do not suffer from this issue.

[1] https://stackoverflow.com/questions/8273546/emacs-how-to-see-how-to-debug-a-single-elisp-function-emacs-command

1 Answer 1


In the end, the solution to all my woes was as per this reddit question [1], which I quote verbatim:

What ultimately fixed it was deleting the unto-treehistory file corresponding to the Org file I was trying to open. The history file itself was a good 280k, probably the largest of all of my undo tree history files. I periodically commit my Org changes to Git, so having that whole history stored is not even providing any value in the long-term, so deleting it was no problem.

I addressed my issue by first disabling undo-tree-mode, at which point I could use Emacs normally again including saving the file. I then found the undo-tree file by looking at the messages buffer, where you should see something like:

Wrote /tmp/.!home!${VERY_LONG_PATH}!${FILE_NAME}.org.~undo-tree~

You can safely delete this file and re-enable undo-tree and Emacs should return back to normal.

[1] https://www.reddit.com/r/emacs/comments/9fs8pp/reentering_top_level_after_c_stack_overflow/

  • 2
    This sounds like a bug in undo-tree. Please consider sending a bug report.
    – NickD
    Commented Mar 14, 2021 at 16:51
  • 3
    @NickD -- I have bug reports from years ago on this issue 27571 and 27779 ... npostavs wrote up a test to reproduce the issue ... and there was some development by the Emacs team to fix this, but I did not spend any time testing the potential fix ... I presently use a Frankenstein version of Emacs that reverts certain code that caused this issue, and I launch Emacs from the terminal after issuing the command ulimit -S -s unlimited
    – lawlist
    Commented Mar 16, 2021 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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