emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

print-circle, and backtraces containing circular structures causing infi


From: Adam Porter
Subject: print-circle, and backtraces containing circular structures causing infinite loop/out-of-memory
Date: Fri, 27 May 2022 02:49:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

Hi,

In my work on Ement.el [0] over the past couple of years, I've gotten reports from users that Emacs would sometimes go into an infinite loop, using all available memory until it's exhausted. I also observed this behavior myself at times.

I finally realized that this happened when an error was signaled and Emacs was trying to print a backtrace containing self-referential data structures (which Ement.el uses). Then I set print-circle to t in my config, and the problem went away. Then I suggested to users that they do the same, and it seems to have fixed the problem for them (those who have seen the suggestion in the readme).

Now, AFAICT it doesn't seem like setting print-circle to t is a good general-purpose solution. For one thing, if it were, it would probably already be the default value. As well, I suppose it might cause issues in other packages that print and read Lisp data.

So, my question: Is there a way to set print-circle only when printing backtraces?

I suppose I could try wrapping the highest level of my code's most common loop in a condition-case that binds print-circle before re-signaling the error, but it seems like Emacs ought to guard against this in all cases. It's not likely that I could anticipate every place in my code where such a guard would need to be installed.

It seems like a potentially severe problem for Emacs to go into this infinite-loop/OOM condition, especially because it may happen when the user is not at the computer: the user can't notice and interrupt with "C-g", instead returning to an unresponsive, OOM system, or to find that the Emacs process was killed (in Ement.el's case, it tends to happen when an event arrives over the network that exposes a bug in Ement, like a malformed event, and the user may be AFK).

Thanks,
Adam

0: https://github.com/alphapapa/ement.el



reply via email to

[Prev in Thread] Current Thread [Next in Thread]