Subject: bug#7920: 24.0.50; Crash in balance_an_interval + 26

From: Stefan Monnier <[email-masked]>
Date: Thu, 27 Jan 2011 12:37:35 -0500

> sent the email... But in short, this has been happening when I'm using slime
> to connect to an emacs-launched clojure shell process.  In particular, it
> happens when clojure hangs, and I don't know how to collect more details at
> this point - next time it happens I'll provide you with more.

Thanks.

> Hmm, this may be indeed the case that my max-specdpl-size is too high.
> This is in part due to me not knowing what "too high" means for my
> machine - how can I calculate the optimal value? I remember having set
> it up to 100000 to be able to use a cedet/javasee function (guided by
> some solution posted on a blog whose name, i'm afraid, i can't
> recall).

Try to set it to a much lower value.  The current default is somewhere
around 1000.  It's not completely abnormal if it turns out to be too low
for some cases, but when you set it higher, be careful to do it in small
increments, at most doubling each time.

> Why should Emacs set this value to anything lower than the
> maximum supported value, does it affect the system
> performance/resources?

There is no "correct" value, sadly.  Basically the value should be set
to "OS-enforced-max-stack-size / expected-stack-frame-size-of-recursion".
AFAIK Emacs doesn't try to find out neither the numerator nor the
denominator, and I don't think the denominator is fixed: it depends on
the exact pattern of recursion.
We should replace (or complete) this test with something that really
tests whether we're running out of stack space: patches welcome.

> It has been working thus far, though, except with this occasional infinite
> recursion using slime. I've now set that variable's value to the default
> (removing my customization), and I'll see if I run into more problems.

Make sure you run with debug-on-error set to t, so that if you bump into
this problem, you should get a (Lisp) backtrace which should help figure
out where's that inf-recursion.

        Stefan