[Python-Dev] Preventing recursion core dumps

Guido van Rossum guido@beopen.com
Fri, 11 Aug 2000 09:28:09 -0500


> > It seems better to tune the generic check than to special-case str,
> > repr, and getattr.
> 
> Right. This would be a step forward, at least for recursive Python code
> (which is the most common complaint).  Reducing the current value
> by half, i.e. setting MAX_RECURSION_DEPTH = 5000 works for me (Linux & AIX)
> 
> Agreement on 5000?

No, the __getattr__ example still dumps core for me.  With 4000 it is
fine, but this indicates that this is totally the wrong approach: I
can change the available stack size with ulimit -s and cause a core
dump anyway.  Or there could be a loger path through the C code where
more C stack is used per recursion.

We could set the maximum to 1000 and assume a "reasonable" stack size,
but that doesn't make me feel comfortable either.

It would be good if there was a way to sense the remaining available
stack, even if it wasn't portable.  Any Linux experts out there?

> Doesn't solve the problem for C code (extensions) though...

That wasn't what started this thread.  Bugs in extensions are just that.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)