f



Segmentation Fault on exit

Hi,

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. Following is the log:

vipul@vipul-laptop:~/ossim-svn/src/pyossim/swig$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyossim
>>>
* Do some stuff *
>>> exit()
Segmentation fault
vipul@vipul-laptop:~/ossim-svn/src/pyossim/swig$

Kindly help.

Thanks and Regards,
Vipul Raheja
0
8/6/2011 10:35:34 AM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies
9567 Views

Similar Articles

[PageSpeed] 20

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

0
8/8/2011 6:56:30 AM
On Aug 6, 6:35=A0am, Vipul Raheja <vipul.ii...@gmail.com> wrote:
> Hi,
>
> 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. Following is the log:
>
> vipul@vipul-laptop:~/ossim-svn/src/pyossim/swig$ python
> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>>=
 import pyossim
>
> * Do some stuff *
> >>> exit()
>
> Segmentation fault
> vipul@vipul-laptop:~/ossim-svn/src/pyossim/swig$
>
> Kindly help.
>
> Thanks and Regards,
> Vipul Raheja

Check out Valgrind.  It's easy to set up, runs like gdb, but keeps
track and flags any offending memory use at the c level. Then just
need to find the calling python code.
0
vacorama (3)
8/10/2011 2:18:46 PM
Reply: