[Patches] [Patch #101352] PyOS_StackCheck for Unix

noreply@sourceforge.net noreply@sourceforge.net
Fri, 05 Jan 2001 08:06:46 -0800


Patch #101352 has been updated. 

Project: python
Category: core (C code)
Status: Open
Submitted by: loewis
Assigned to : loewis
Summary: PyOS_StackCheck for Unix

Follow-Ups:

Date: 2001-Jan-05 08:06
By: jhylton

Comment:
The current solution to stack limits for Unix is simpler, but probably good
enough.  Are you still interested in pursuing the approach in this patch?

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

Date: 2000-Aug-30 02:15
By: lemburg

Comment:
Since getrlimit() might not return useful results on all Unix
platforms, I'd suggest adding a test to the configure script
(the test should check whether getrlimit() returns a non-zero
value for the stack limit).

Also, due to the added call overhead, I'd suggest raising the
modulo value in ceval's hook to call PyOS_CheckStack():

#ifdef USE_STACKCHECK
        if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) {
                PyErr_SetString(PyExc_MemoryError, "Stack overflow");
                return NULL;
        }
#endif

to about 100. 

That way the stack check will most likely only be
triggered by programs which actually use recursion, rather than
those which only use shallow function call nesting (10 seems
to low w/r to these).

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

Date: 2000-Aug-30 05:31
By: loewis

Comment:
IMO,  testing could be deferred until some system shows up that indeed
returns
zero. As for the frequency of the OS call, it may be useful to cache the
result
of getrlimit, on a per-thread basis. That won't catch changes done by the
script itself, or from the outside, but if people do such things, they need
to
be careful, anyway.
-------------------------------------------------------

Date: 2000-Aug-30 12:52
By: gvanrossum

Comment:
Given to Jeremy. We don't think we can get PyOS_CheckStack to work reliably
and efficiently on Unix. Instead, we're going to make the recursion limit a
user settable thing (sys.{set,get}recursionlimit) with a small default,
e.g. 1000.
-------------------------------------------------------

Date: 2000-Aug-30 18:33
By: jhylton

Comment:
Postponed, because it is sufficiently complex to fall subject to the
feature freeze for 2.0b1.

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

Date: 2000-Nov-01 04:29
By: moshez

Comment:
Two things:

1) For GOD's sake, don't use #if inside #else: #elif
   makes a mess not worse then it has to be
2) I'm not sure this patch is very "honest": Py_Initialize() can be called
from a call hierarchy either shallower or deaper then, say,
Py_CallObject(..) 
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101352&group_id=5470