how to debug when "Segmentation fault"

Jp Calderone exarkun at divmod.com
Tue Oct 4 15:08:27 EDT 2005


On Tue, 4 Oct 2005 11:22:24 -0500, Michael Ekstrand <mekstran at scl.ameslab.gov> wrote:
>On Tuesday 04 October 2005 11:13, Maksim Kasimov wrote:
>> my programm sometime gives "Segmentation fault" message (no matter
>> how long the programm had run (1 day or 2 weeks). And there is
>> nothing in log-files that can points the problem. My question is how
>> it possible to find out where is the problem in the code? Thanks for
>> any help.
>
>What extension modules are you using?
>
>I've never seen "stock" Python (stable release w/ only included modules)
>segfault, but did see a segfault with an extension module I was using
>the other week (lxml IIRC, but I'm not sure).
>

exarkun at boson:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.setrecursionlimit(1e9)
__main__:1: DeprecationWarning: integer argument expected, got float
>>> (lambda f: f(f))(lambda f: f(f))
Segmentation fault
exarkun at boson:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class foo(type):
...     def mro(self):
...         return [float]
... 
>>> class bar:
...     __metaclass__ = foo
... 
Segmentation fault
exarkun at boson:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dl
>>> dl.open('libc.so.6').call('memcpy', 0, 0, 1024)
Segmentation fault
exarkun at boson:~$ 

Though to be honest, even I consider the 3rd example a bit of a cheat ;)

Jp



More information about the Python-list mailing list