[Python-Dev] test_sre.py fails on Win64 because PyOS_CheckStack *never* fails

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 4 Oct 2000 23:43:41 +0200


trent wrote:
> This is because PyOS_CheckStack seem to *never* fail on Win64. Three
> possibilites:
>   (1) I don't understand the PyOS_CheckStack code or I am misintepreting the
>       problem.
>   (2) The semantics of _alloca() has changed for Win64 such that a stack
>       overflow exception is no longer thrown if space cannot be allocated.
>       NOTE: I changed the number of pointers allocated in PyOS_CheckStack
>             from 2048 to over 1 *Tera*byte and it *still* did not fail.

me again: didn't read the note carefully enough, so I didn't
quite figure out what you said...

:::

what happens if you run this program (on my win95 box, it
counts up to 8, and stops).

#include <malloc.h>
#include <excpt.h>

int __inline
PyOS_CheckStack()
{
    __try {
        _alloca(100000);
        return 0;
    } __except (EXCEPTION_EXECUTE_HANDLER) {
        /* just ignore all errors */
    }
    return 1;
}

void
callme(int i)
{
    char buf[100000];
    if (PyOS_CheckStack())
        return;
    printf("%d\n", i);
    memset(buf, 0, sizeof buf);
    callme(i+1);
}

int
main()
{
    callme(0);
}

:::

if it goes on and on and on, check the assembler output from
this program.

(maybe the win64 compiler is smarter than I -- if it realizes that I
don't actually use the return value from _alloca, it may of course
remove the entire thing...)

</F>