Segmentation fault with Py_Finalize()

Gal Aviel galaviel at yahoo.com
Sun Aug 10 04:08:46 EDT 2008


Hello All,

I Need some tips/help/ideas debugging segmentation fault ... 

I'm trying to debug Python running embedded inside a Verilog
Simulator (as a SystemVerilog DPI application). (on SUSE LINUX 
Enterprise Server 9 (i586))

The Embedded python loads two SWIG wrapped modules (written in C and C++).

All goes well until finally I try to destroy the interpreter using 
Py_Finalize(). Seems like Python's garbage collection is trying to 
free something it's not suppose to free (thinks it owns it 
but has been freed already? Python/SWIG ownership issues?)

MY question: how can tell the name of the object that visit_decref() 
below is trying to free? or at least, when/where it was allocated
in my code?

I'm not really a Software guy, but I have TotalView Enterprise 
at my disposal and I noticed it has memory debugging capabilities.

Can I somehow know when the pointer/object that is trying to be freed was
allocated and where? what it is?

Many many thanks in advance,

Gal.

The details..

The stack trace:

Stack Trace
C    visit_decref,         FP=bfff9258
C    dict_traverse,        FP=bfff9298
C    collect,              FP=bfff9368
C    PyGC_Collect,         FP=bfff9378
C    Py_Finalize,          FP=bfff9398
C    destroy_python,       FP=bfff93b8


The stack frame for visit_decref():

Stack Frame
Function "dict_traverse":
  op:                0x50de3934 (Allocated Interior) -> (PyObject)
  visit:             0x4e81a600 : visit_decref
  arg:               0x00000000
Block "$b1":
  vret (%eax):       0x00000000 (0)
Local variables:
  i:                 0x00000001 (1)
  pk:                0x5092e320 (Allocated Interior) -> (PyObject)
  pv:                0x094dfc98 (Allocated Interior) -> (PyObject)






More information about the Python-list mailing list