[ILUG] Segmentation Fault
Aidan Kehoe
kehoea at parhasard.net
Thu Sep 13 14:35:13 IST 2001
Ar an 13u la de mi 9, scriobh Michael Treacy :
>
> Ok, here's the question: in general, what causes segmentation faults?
>
The address space of a program is divided into segments; only some of
those segments, notably the stack (where local variables are stored)
and the heap (where malloc'ed ones (in C) are), are writable. Try to
write anywhere else (e.g. to a constant string, to the address 0, to
the address -1) and you have a segmentation fault. So, it means you're
writing where you're not supposed to.
> I've gone through the second fortran program, even added in print commands
> to see how far down the program, I was getting, but the first one isn't even
> reached.
Does it reach it when you're not trying to read this input file? Have
you tried reading from another input file? I'd advise trying GDB,
except it doesn't seem to like fortran, unfortunately;
(gdb.info)
GDB can be used to debug programs written in Fortran, although it
does not yet support entering expressions, printing values, or similar
features using Fortran syntax. It may be necessary to refer to some
variables with a trailing underscore.
Chris Higgins' strace suggestion is probably the way to go. If you're
not on Linux, investigate ktrace (some BSD) and truss (SVR4).
--
`... when the elephant man broke strong men's necks, when he'd had too
many Powers, ...'
More information about the ILUG
mailing list