[Python-bugs-list] [ python-Bugs-580824 ] getattr crasher

noreply@sourceforge.net noreply@sourceforge.net
Tue, 16 Jul 2002 12:02:02 -0700


Bugs item #580824, was opened at 2002-07-12 18:54
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=580824&group_id=5470

Category: Python Interpreter Core
>Group: Python 2.2.1
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: Arman Bostani (arman0)
Assigned to: Neal Norwitz (nnorwitz)
Summary: getattr crasher

Initial Comment:
The following crashes the interpreter.

class test:
    def __getattr__(self, attr):
        return self

test()()


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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-16 15:02

Message:
Logged In: YES 
user_id=33168

I worked on it, but Guido fixed it. 
http://python.org/sf/532646 is the relevant bug.
Guido backported the change (Objects/classobject.c:2.154.8.1).
I can't duplicate in 2.2.1+, so this should be fixed in 2.2.2.
Closing as duplicate.

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

Comment By: Jeremy Hylton (jhylton)
Date: 2002-07-16 14:39

Message:
Logged In: YES 
user_id=31392

I only test with Python CVS, where the example raises an
exception.  It sounds like we should backport Neal's fix to 2.2.


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

Comment By: Arman Bostani (arman0)
Date: 2002-07-16 14:33

Message:
Logged In: YES 
user_id=577382

Sorry, I should have mentioned initially that I've seen this
on 1.5.x, 2.0 and 2.1.3.  I just tried version 2.2.1 on
Win2k and it also crashes.



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

Comment By: Tim Peters (tim_one)
Date: 2002-07-16 14:13

Message:
Logged In: YES 
user_id=31435

Arman, which version of Python are you using (1.5.2, 2.0, 
2.1, 2.1.3, 2.2.1, etc)?

I believe Neal Norwitz added additional recursion-depth 
checking in the current CVS head, so in some sense the 
most interesting question is whether you still see this happen 
in a CVS build (I do not, on Windows).  Jeremy, do you still 
see it?

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

Comment By: Arman Bostani (arman0)
Date: 2002-07-16 14:04

Message:
Logged In: YES 
user_id=577382

I'm running on Linux 2.4.17.  

I don't think this type of recusrion is actually counted by
ceval right now.  At the time of the crash
tstate->recursion_depth is 2.  So, setting recusrion limits
will not help.

-arman


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

Comment By: Jeremy Hylton (jhylton)
Date: 2002-07-16 13:00

Message:
Logged In: YES 
user_id=31392

What platform are you running on?  The interpreter tries to
catch this infinite recursion, but there's no portable way
to tell how many C stack frames are too many.

The functions sys.getrecursionlimit() and
sys.setrecursionlimit() can be used to affect this behavior.
 If you set the recursion limit to a lower number, you can
prevent the crash.  The script Misc/find_recusionlimit.py
will find a safe number for you.


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

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