how to debug when "Segmentation fault"

Tamer Fahmy tamer at remove-this-tammura.at-and.this
Wed Oct 5 08:53:45 EDT 2005


On Tue, 04 Oct 2005 19:13:10 +0300, 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.
> 
> Python 2.2.3
> FreeBSD

you could start your program within a gdb session like so:

$ gdb python
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc. GDB is free software,
covered by the GNU General Public License, and you are welcome to change
it and/or distribute copies of it under certain conditions. Type "show
copying" to see the conditions. There is absolutely no warranty for GDB. 
Type "show warranty" for details. This GDB was configured as
"i386-marcel-freebsd"...(no debugging symbols found)...
(gdb) r foo.py
Starting program: /usr/bin/python foo.py ...

once your progmam segfaults you can then inspect the stack through:

(gdb) bt

cheers,
  tamer.

-- 
  hardware, n: The parts of a computer system that can be kicked.





More information about the Python-list mailing list