[Python-Dev] possible fix for recursive call segfault (original) (raw)
Brett Cannon brett at python.org
Tue Apr 18 20:19:09 CEST 2006
- Previous message: [Python-Dev] possible fix for recursive __call__ segfault
- Next message: [Python-Dev] How to make _sre.c compile w/ C++?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4/18/06, Armin Rigo <arigo at tunes.org> wrote:
Hi Brett,
On Mon, Apr 17, 2006 at 05:34:16PM -0700, Brett Cannon wrote: > + if (meth == self) { > + PyErrSetString(PyExcRuntimeError, > + "recursive call definition"); > + return NULL; > + } This is not the proper way, as it can be worked around with a pair of objects whose call point to each other.
Yeah, I know. It was just a quick hack that at least helped me identify where the problem was. I didn't really expect for it to stick around.
The solution is to use the counter of Py{Enter,Leave}RecursiveCall(), as was done for old-style classes (see classobject.c).
OK. Makes sense.
By the way, this is a known problem: the example you show is Lib/test/crashers/infiniterec3.py, and the four other infiniterec*.py are all slightly more subtle ways to trigger a similar infinite loop in C. They point to the SF bug report at http://python.org/sf/1202533, where we discuss the problem in general. Basically, someone should try to drop many Py{Enter,Leave}RecursiveCall() pairs in the source until all the currently-known bugs go away, and then measure if this has a noticeable performance impact.
OK, good to know. I will have to fix this eventually for sandboxing reasons for my dissertation so I will get to it eventually.
-Brett
- Previous message: [Python-Dev] possible fix for recursive __call__ segfault
- Next message: [Python-Dev] How to make _sre.c compile w/ C++?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]