segfault in extension module

Nathaniel Echols echols at OCF.Berkeley.EDU
Sun Nov 30 19:19:45 EST 2003


I've written a function in C to perform protein sequence alignment.  This
works fine in a standalone C program.  I've added the necessary packaging
to use it in Python; it returns three strings and an integer.  However, as
soon as the function is complete, I get a segfault and the interpreter
dies.

If I run Python interactively, just calling the function causes a
segfault.  If I'm running a script, I can actually print out the return
values (which are what I'd expect - so something's working) but as soon as
the script is done I get the segfault again.  I can even call the function
twice, with different arguments - and it works both times.  So it appears
that the problem is with tying up loose ends.

How do I determine what is going wrong?  I do not get any problem like
this in the C version.  I am not using free() anywhere - I will eventually
need to fix this, but I cannot find any place where I might be accessing
unavailable memory.  (Adding in free() does not make any difference in the
module, for what it's worth, but I've had some issues with the C program
so I've left it out.)

[I've also tried using PyMem_Malloc instead, throughout the C code.
Doesn't help.]

thanks,
Nat
(please reply directly!)




More information about the Python-list mailing list