[Python-Dev] multiple recursion limit bugs

Dan wolfe wolfeman@mac.com
Mon, 11 Mar 2002 09:49:36 -0800


On Monday, March 11, 2002, at 09:25  AM, Skip Montanaro wrote:

>     [... regarding sre recursion limits ...]
>>>
>>> I recently added an example that demonstrates the problem, but I
>>> think the main issue is that the limitation needs to be better
>>> documented.  We can then close most/all of these bug reports as "not
>>> a bug" or "known implementation limitation".  Does this seem like the
>>> right approach?
>
>     Jack> As long as all the stack overflow possibilities are protected 
> with
>     Jack> PyOS_CheckStack() calls. In the past that wasn't always the 
> case,
>     Jack> and this created havoc on operating systems without hardware 
> stack
>     Jack> limits.
>
> I looked in _sre.c and saw that it does call PyOS_CheckStack, but it's
> guarded by the USE_STACKCHECK macro:
>
>     #if defined(USE_STACKCHECK)
>         if (level % 10 == 0 && PyOS_CheckStack())
>             return SRE_ERROR_RECURSION_LIMIT;
>     #endif
>
> That's defined in Include/pythonrun.h for a few platforms:
>
>     #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
>     /* Enable stack checking under Microsoft C */
>     #define USE_STACKCHECK
>     #endif
>
> Should it also be defined for MacOS versions predating MacOS X (or is 
> this
> defined elsewhere for the Mac platform)?

At one time (2.0/2.1 era) I had a patch (unfortunately I've misplaced 
it) to fix the problem with the small stack size (512K) on Mac OS X but 
put it aside as Fredrik was going to do some changes to SRE engine to 
fix this problem... I haven't hear anything on this topic lately so I'm 
not sure what the status is these days.... perhaps we should check with 
Fredrik to see what he has up his sleeves with the SRE before 
implementing any changes.

- Dan