[Python-bugs-list] python dumps core on my script (PR#207)

Skip Montanaro skip@mojam.com (Skip Montanaro)
Thu, 17 Feb 2000 11:54:57 -0600 (CST)


    tim> It's really that you've forced the interpreter into infinite
    tim> recursion.  Thinking about this one should make it clear:

It would appear that MAX_RECURSION_DEPTH in ceval.c is set too big, at least
on my system (Mandrake Linux 6.1).  I tried the following:

    >>> import misc
    >>> class foo:
    ...   def __init__(self):
    ...     self.ticker = misc.Progress()
    ...   def __repr__(self):
    ...     self.ticker.tick()
    ...     print self

misc.Progress is a little progress meter class I often use in highly
iterative console programs.  Instantiating foo and printing the instance
yielded:

    >>> f = foo()
    >>> print f
    .........1.........2.........3.Segmentation fault

This suggests to me that I got about 3100 recursive __repr__ calls under my
belt before it crapped out.  I'm sure stackless python will minimize this
problem (it won't fix the bug, but it should get well past 10,000 calls
before faulting ;-).

Should MAX_RECURSION_DEPTH be set to something smaller (say, 1000) or should
configure try to figure out a reasonable number?  Unless you're computing
Ackerman's function or something equally brutal, I would think a recursion
depth of 1,000 would be adequate.  Regardless of the source of the error, it
seems like a case where we might want to try harder to avoid an interpreter
crash (unless Guido is on the verge of adopting SP, of course).

Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/
"Languages that change by catering to the tastes of non-users tend not to do
so well." - Doug Landauer