[Python-Dev] Fw: Access violation when no memory

Mark Hammond mhammond@skippinet.com.au
Tue, 20 Jun 2000 21:42:53 +1000


From the newsgroup.  Any thoughts?

Mark.

"Phil Mayes" <nospam@bitbucket.com> wrote in message
news:<olD35.82$_%.4481@newsfeed.avtel.net>...
> The following program progressively allocates all memory:
>     size = 1 << 20
>     list = [None,]
>     while size:
>         try:
>             mem = [None] * size
>             mem[0] = list
>             list = mem
>         except:
>             size = size / 2
>
> It fails with an access violation.  (Turn off virtual memory
> to provoke it.)  This is not a theoretical situation for me:
> I have a beta release in the field that is crashing like this.
> The immediate cause is this:
>
> 1. we are handling a MemoryError
> 2. the following call cannot allocate a traceback object
>      ceval.c line 1800:    PyErr_Fetch(&exc, &val, &tb);
> 3. the NULL pointer at tb is pushed here:
>      ceval.c line 1816:    PUSH(tb);
>      ceval.c line 1817:    PUSH(val);
>      ceval.c line 1818:    PUSH(exc);
> 4. later it is popped here and its ref count is decremented:
>      ceval.c line 682:    case POP_TOP:
>      ceval.c line 683:        v = POP();
>      ceval.c line 684:        Py_DECREF(v);
>      ceval.c line 685:        continue;
>
> This is with 1.5.2 but the crash still happens with 1.6a2.
> At this stage I am way out of my depth, and  the only way I
> see to fix this is to change Py_DECREF to Py_XDECREF, which
> is a (minor?) inefficiency. Can anyone recommend a better way?
>
> And should I report this at http://www.python.org/python-bugs?
> I do not have access to the current CVS tree.
>
> TIA, Phil Mayes
> --
> pmayes AT olivebr DOT com
>
>
>