This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: __getattr__ = getattr crash
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: arigo Nosy List: arigo, ferringb, nnorwitz
Priority: high Keywords:

Created on 2006-11-03 16:44 by ferringb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getattr.patch nnorwitz, 2006-11-04 19:40 v1
Messages (4)
msg30438 - (view) Author: Ferringb (ferringb) * Date: 2006-11-03 16:44
class c(object):__getattr__ = getattr
c().spam

<segfault from overflowing the c stack>

Now granted... it's retarded to attempt this.  But out
of curiousity, I decided to be the retard, and noticed
the interpreter crashes instead of triggering a
RuntimeError for recursion.

As far as I know, getattr is instrumented with
Py_EnterRecursiveCall and Py_LEaveRecursiveCall... so a
bit curious as to how it's occuring.
msg30439 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-11-04 19:40
Logged In: YES 
user_id=33168

The attached patch fixes this problem.  However, I'm
concerned there are more places like this.  I hope Armin has
some ideas if more things are needed to fix this problem.
msg30440 - (view) Author: Ferringb (ferringb) * Date: 2006-11-05 03:57
Logged In: YES 
user_id=874085

can do the same trick with hasattr also (same type of fix)...
msg30441 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-11-05 09:30
Logged In: YES 
user_id=4771

This is a particular case of bug #1202533.

With Brett we arrived at a patch in #1202533 which
should solve a family of similar problems.  Can you
check that it also solves the __getattr__=getattr
attack?  If so, we should check in Brett's patch.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44192
2006-11-03 16:44:20ferringbcreate