how to debug when "Segmentation fault"

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Tue Oct 4 13:29:37 EDT 2005


Maksim Kasimov a écrit :
> 
> Hello,
> 
> 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
> 

Well, your best bet is to generate a core file !
To do so, in the shell launching the program, you need to accept core
files. The command is :

$ ulimit -c <max size of core file accepted>

For example:
$ ulimit -c 500000

For a 500MB max file.

Then, if your program crash, you should see a file named "core.XXXX"
where XXXX is the PID of the process. You can know exactly where the
program crashed using gbd :

$ gdb --core=core.XXXX

Then, depending on the debug information you have in your executables
you may (or may not) be able to know what happened :)

Pierre



More information about the Python-list mailing list