how to debug when "Segmentation fault"

Michael Ekstrand mekstran at scl.ameslab.gov
Tue Oct 4 15:18:21 EDT 2005


On Oct 4, 2005, at 2:08 PM, Jp Calderone wrote:
> On Tue, 4 Oct 2005 11:22:24 -0500, Michael Ekstrand 
> <mekstran at scl.ameslab.gov> wrote:
>> 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:~$

I stand corrected.

Except for the 2nd one, where I'm not quite sure what's going on, I'd 
say I have yet to see the Python interpreter crash when doing "normal" 
things not involving C esoteria (for some definition of normal not 
including setting the recursion limit to 1e9).

Or  maybe my total faith in Python to keep me from ever having to think 
about memory problems when doing high-level coding is misplaced, but 
I'd like to think not...

- Michael




More information about the Python-list mailing list