[Patches] Re: [Patch #101238] PyOS_CheckStack for Windows (MSVC)

Guido van Rossum guido@beopen.com
Tue, 22 Aug 2000 07:57:31 -0500


> guido:
> > This looks fine to me -- but when I test it (VC 6 on Win98), it doesn't
> > work.  Try this:
> > 
> > class C:
> >   def __getattr__(self, a): return self.x
> > 
> > C()
> > 
> > This still aborts the program.

effbot:
> note that I've just implemented the CheckStack operation for
> MSVC; I didn't plug more holes in the interpreter.  see the
> attached patch for an attempt to fix this one.

Hm.  My reasoning was that since CheckStack is called every 10
recursions by ceval.c, and the above example clearly executes Python
code at each recursion, it should be caught.  Why isn't it?  is the
margin (2K) too small for 10 recursions?

> (it seems to work, but the getattr code is a bit convoluted, so
> it's possible that the stack check should really be placed some-
> where else...)
> 
> > As shown it breaks the build for _sre because the declaration for
> > PyOS_CheckStack() doesn't use DL_IMPORT().  (MSVC 6.0 on Win98.)
> 
> well, I just rebuilt the core interpreter, and tested the __str__
> and __repr__ cases (Bug #110615).  this glitch is fixed in the
> new patch.

I'll look at it more when I have more time.  (Today we've got a group
meeting all day first.)

> :::
> 
> CheckStack is also used to prevent run-away recursion in main
> interpreter, but the recursion limit check catches that before you
> run out of stack on Windows (with a standard stack, that is).
> 
> maybe the recursion limit check should be disabled if CheckStack
> is available?

I think so.  But it ought to be tested.

Have you timed this?

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)