[SciPy-user] f2py "Segmentation fault", please help

Robert Kern robert.kern@gmail....
Wed Jun 11 17:07:24 CDT 2008

On Wed, Jun 11, 2008 at 16:57, Kimberly Artita <kartita@gmail.com> wrote:
> I recently updated my system (including python, scipy, numpy) and now get a
> bizarre "Segmentation fault" message where I didn't before.
> I have problems reading in data.  Here is any example from my fortran file
> (*.f90):
>      character(len=4) :: title(60)
>      open (2,file="file.cio")
>      read (2,5100) title
>      5100 format (20a4)
> The file "file.cio" contains this:
> General Input/Output section (file.cio):           Thu Mar 13 17:32:19 2008
> AVSWAT2000 - SWAT interface MDL
> Previously, it read in the data as :"General Input/Output section
> (file.cio):           Thu Mar 1"
> But now all I get is: "Segmentation fault" and then my program stops.

We need some more information. Can you show us the code? Alternately,
can you narrow the code down to just the part that is crashing? Please
run your program under a C debugger like gdb in order to get a
backtrace which will show us exactly where things are segfaulting.

Here is what that looks like on OS X. The details will be different on
other UNIces, but the "run -c ...", "continue", "backtrace" steps
should be the same.

$ gdb python
GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct  2 04:07:49 UTC 2007)
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-apple-darwin"...Reading symbols for
shared libraries .. done

(gdb) run -c crashing_script.py any_other_necessary_arguments_for_your_script
Starting program: /usr/local/bin/python -c crashing_script.py
Reading symbols for shared libraries +. done

Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe01010 in __dyld__dyld_start ()
(gdb) continue
Reading symbols for shared libraries .. done

... segfault happens here ...

(gdb) backtrace

... backtrace output here; this is what we need to see ...

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

More information about the SciPy-user mailing list