[Numpy-discussion] crash in C++ extension module on process shutdown

Geoffrey Irving irving@naml...
Sat Mar 5 18:02:35 CST 2011


Hello,

I have an extension module which holds on to a reference to a numpy
array in a static variable.  When the process shuts down, the C++
destructor triggers array_dealloc via Py_DECREF, and I get

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000048
0x00000001000c7c0e in PyErr_Occurred ()

This is after Py_Finalize, so presumably what I'm doing is technically
wrong, but I'm wondering if there's any easy way to make it not die.
I'm using Python 2.6 with Numpy 1.5.1; the code works fine with Python
2.5.  The stack trace is

#0  0x00000001000c7c0e in PyErr_Occurred ()
#1  0x000000010252cdd9 in array_dealloc ()
#2  0x000000010296f06d in Try::ARRAY<int, 1>::~ARRAY
(this=0x102990250) at ARRAY.h:138
During symbol reading, inner block (0x102962c90-0x102962cd4
'_ZN3Try5ARRAYIKiLi1EEC1Ev') not inside outer block
(0x102962d84-0x10297ef30).
During symbol reading, inner block (0x102962c42-0x102962c4c
'_ZN3Try10ARRAY_BASEIKiNS_5ARRAYIS1_Li1EEEEC2Ev') not inside outer
block (0x102962c90-0x10297ef30).
During symbol reading, inner block (0x102962c38-0x102962c42
'_ZN3Try10ARRAY_BASEIiNS_5ARRAYIiLi1EEEEC2Ev') not inside outer block
(0x102962c42-0x10297ef30).
During symbol reading, inner block (0x102962c38-0x10297ef30) not
inside outer block (0x102962d84-0x10297ef30).
#3  0x000000010297eefa in __tcf_1 () at Arrays/Module.cpp:9
#4  0x00007fff856678d4 in __cxa_finalize ()
#5  0x00007fff856677ec in exit ()
#6  0x00000001000ddcfd in handle_system_exit ()
#7  0x00000001000ddf45 in PyErr_PrintEx ()
#8  0x00000001000dec5a in PyRun_SimpleFileExFlags ()
#9  0x00000001000ee40c in Py_Main ()
#10 0x0000000100000f14 in ?? ()

Thanks in advance for any suggestions!

Geoffrey


More information about the NumPy-Discussion mailing list