Access violation when no memory

Phil Mayes nospam at bitbucket.com
Tue Jun 20 01:20:46 EDT 2000


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






More information about the Python-list mailing list