need help checking for stack overflow in Win32

Jim Rudnicki jdrudnicki at yahoo.com
Wed Jun 2 04:06:13 EDT 1999


> I could use some help from someone with a little time, some knowledge
> of Python internals, and some Win32 C expertise.  On Win32 platforms,
> infinite recursion causes an Application Error (a fatal windows
> error).  There is some machinery in Python to check for this
> condition, but apparently it doesn't work on Win32.  Please help!

My vague memory is that page fault exceptions are thrown as the stack grows.
Unfortunately, everything is throwing page faults keeping the virtual memory
manager busy.  Hooking into that exception handler seems like real work.

Not knowing what is going on inside, let me ask this: how do you count
recursion depth?  I presume a counter somewhere (no duh).  How about instead
of counting calls, you count cumulative space pushed.  Now, the recursion
limit would be in bytes.  This allows many calls for functions with small
parameter lists, but also accomodates the program that trys to pass bitmaps
on the stack.  You set it to 800,000 and it always works?  Now of course the
SP itself is this count.  If we could only get that...

I'll try looking through Richter tommorrow and see if anything pops out (no
pun intended)

Jim






More information about the Python-list mailing list