[ python-Bugs-1201456 ] Problem with recursion in dict (crash with core dump)

SourceForge.net noreply at sourceforge.net
Mon May 23 06:29:45 CEST 2005


Bugs item #1201456, was opened at 2005-05-13 08:43
Message generated for change (Comment added) made by josiahcarlson
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1201456&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Closed
Resolution: Wont Fix
Priority: 5
Submitted By: Vladimir Yu. Stepanov (vys)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem with recursion in dict (crash with core dump)

Initial Comment:
Please see example code. 

----------------------------------------------------------------------

Comment By: Josiah Carlson (josiahcarlson)
Date: 2005-05-22 21:29

Message:
Logged In: YES 
user_id=341410

If your system has sufficient stack space (and/or a
reasonably sane malloc), a recursion limit of 1000 should be
fine.  My windows systems print tracebacks properly for up
to a recursion limit of around 5750 levels (after which I
get MemoryErrors with tracebacks, not cores).

Place a sys.setrecursionlimit() call in your site.py.

----------------------------------------------------------------------

Comment By: Vladimir Yu. Stepanov (vys)
Date: 2005-05-18 06:05

Message:
Logged In: YES 
user_id=384980

sys.getrecursionlimit() returns 1000. 
I set sys.setrecursionlimit() to 500 and problem was resolved :) 
 
Thank you very much ! 
 
PS. Is it possible to add some checks in Py_SetRecursionLimit  
to reject overflow values ? 

----------------------------------------------------------------------

Comment By: Nick Coghlan (ncoghlan)
Date: 2005-05-18 05:15

Message:
Logged In: YES 
user_id=1038590

What does sys.getrecursionlimit() return?

Does the buggy code generate the expected exception if you
use sys.setrecursionlimit() to make the value smaller (e.g.
500)?

FreeBSD has a history of not playing well with CPython's
ability to detect inifinite recursion. . .

----------------------------------------------------------------------

Comment By: Vladimir Yu. Stepanov (vys)
Date: 2005-05-13 09:06

Message:
Logged In: YES 
user_id=384980

This is output from `uname -a`: 
FreeBSD fox.renet.ru 5.3-RELEASE FreeBSD 5.3-RELEASE 
#1: Fri Apr 15 10:38:49 MSD 2005     
root at fox.renet.ru:/M/safedir/src/sys/i386/compile/FOX  i386 
 
I get some others with this code: 
 
Python 2.4.1 (#2, Apr 26 2005, 14:16:31) 
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 
Type "help", "copyright", "credits" or "license" for more 
information. 
>>> d = {} 
>>> 
>>> class test: 
...         def __hash__(self): 
...                 d[self] = None 
... 
>>> d[test()] = None 
Bus error (core dumped) 
 
 
fox:vys!~ > gdb python python.core 
GNU gdb 6.1.1 [FreeBSD] 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public 
License, and you are 
welcome to change it and/or distribute copies of it under 
certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB.  Type "show 
warranty" for details. 
This GDB was configured as "i386-marcel-freebsd"...(no 
debugging symbols found)... 
Core was generated by `python'. 
Program terminated with signal 10, Bus error. 
<skip> 
(gdb) where 
#0  0x2828b3b1 in ldexp () from /lib/libc.so.5 
#1  0x2828b618 in malloc () from /lib/libc.so.5 
#2  0x080bdca1 in _PyObject_GC_Malloc () 
#3  0x080bdd4a in _PyObject_GC_New () 
#4  0x0805f556 in PyMethod_New () 
#5  0x0805c1a6 in PyInstance_NewRaw () 
#6  0x0805c66a in PyInstance_New () 
#7  0x0805cca1 in _PyInstance_Lookup () 
#8  0x080703e6 in PyDict_SetItem () 
#9  0x0809bb0e in PyEval_EvalFrame () 
#10 0x0809fc20 in PyEval_EvalCodeEx () 
#11 0x080d4d66 in PyFunction_SetClosure () 
#12 0x0805a38c in PyObject_Call () 
#13 0x0805fbe2 in PyMethod_New () 
#14 0x0805a38c in PyObject_Call () 
#15 0x08099f1b in PyEval_CallObjectWithKeywords () 
#16 0x0805ccb9 in _PyInstance_Lookup () 
#17 0x080703e6 in PyDict_SetItem () 
#18 0x0809bb0e in PyEval_EvalFrame () 
#19 0x0809fc20 in PyEval_EvalCodeEx () 
#20 0x080d4d66 in PyFunction_SetClosure () 
#21 0x0805a38c in PyObject_Call () 
#22 0x0805fbe2 in PyMethod_New () 
<and so on> 

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-05-13 08:55

Message:
Logged In: YES 
user_id=80475

I get the expected behavior:

  RuntimeError: maximum recursion depth exceeded


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2005-05-13 08:55

Message:
Logged In: YES 
user_id=6656

I get an infinite recursion runtime error.  What platform
are you on?

----------------------------------------------------------------------

Comment By: Vladimir Yu. Stepanov (vys)
Date: 2005-05-13 08:46

Message:
Logged In: YES 
user_id=384980

d = {} 
 
class test: 
        def __hash__(self): 
                d[self] = None 
 
d[test()] = None 

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2005-05-13 08:46

Message:
Logged In: YES 
user_id=6656

I see no code.  SF can be a pain with this...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1201456&group_id=5470


More information about the Python-bugs-list mailing list