Segmentation Fault on exit

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Mon Aug 8 08:56:30 CEST 2011


Vipul Raheja wrote:
> I have wrapped a library from C++ to Python using SWIG. But when I
> import it in Python, I am able to work fine with it, but it gives a
> segmentation fault while exiting.

1. Use a debugger
Run python with "gdb python", import the module and exit. The debugger 
should then show you where the segmentation fault occurs, even though that 
code isn't necessarily the code that is at fault itself.

2. Reduce the size of your module
Remove code from the module. The most drastic variant is to strip anything 
and only leave an empty init function. If that still causes troubles, I'd 
suspect something in the environment or in the way you build the module.

3. Make sure the environment works
Try compiling and running the SWIG examples or any other SWIG code. Does it 
work? What are the differences to your code?

4. Post your code
If everything fails, you could try to reduce your module to the bare minimum 
and post that here. Make sure you really remove anything that's not 
necessary.


Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list