首 页文章中心

Linux学习网

您的位置Linux学习网 > Linux程序开发 > 文章内容

请教大侠:Segmentation fault

作者:佚名  来源:不详  发布时间:2007-6-4 8:12:00
各位大侠,我是刚接触 linux 的,不得不在这个系统下调试 fortran 程序。由于时间很紧,强度很大,所以在网上搜了很多天也没有很大进展,现不得不求助各位大侠,告诉我下一步要怎么做,或者看些哪方面的书才能继续下去。
是这样的,老师给了我一个fortran源程序,之前在 UNIX 下编译并成功运行过,现在我用的是 linux ,已经编译成功,但是运行就出错,先给出我的编译文件:
class='codetop'>CODE: class='codemain'>[hujinhe@console ~]$ cat com
mpif77 -g mdrdipord.f -c
mpif77 -g libmd.f -c
mpif77 -g dceign.f -c
mpif77 -g mdrdipord.o libmd.o dceign.o -o mdord.exe
[hujinhe@console ~]$

运行结果如下:
class='codetop'>CODE: class='codemain'>[hujinhe@console ~]$ ./mdord.exe <in.dip> out.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
mdord.exe 000000000041E998 Unknown Unknown Unknown
mdord.exe 0000000000405C6A Unknown Unknown Unknown
mdord.exe 0000000000403074 Unknown Unknown Unknown
mdord.exe 000000000040302A Unknown Unknown Unknown
libc.so.6 000000378851C4BB Unknown Unknown Unknown
mdord.exe 0000000000402F6A Unknown Unknown Unknown
[hujinhe@console ~]$

所以我就学习用gdb调试,出现下面的情况:
class='codetop'>CODE: class='codemain'>[hujinhe@console ~]$ gdb ./mdord.exe
GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
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 "x86_64-redhat-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".

(gdb) run <in.dip> out.out
Starting program: /export/home/hujinhe/mdord.exe <in.dip> out.out
[Thread debugging using libthread_db enabled]
[New Thread 182894224864 (LWP 13692)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 182894224864 (LWP 13692)]
0x000000000041e998 in rand_ ()
(gdb) backtrace
#0 0x000000000041e998 in rand_ ()
#1 0x0000000000405c6a in start () at mdrdipord.f:559
#2 0x0000000000403074 in main$mdrdipord_$BLK () at mdrdipord.f:36
#3 0x000000000040302a in main ()
(gdb)

为了学会调试程序,我把论坛上介绍的有关帖子都看了,发现文章很好,就是例子很少,我大概的命令都知道,就是不会实际应用,所以遇到上面的问题我就不知道怎么办了,大概知道是段错误,但怎么看具体错误出在哪?接下来我要怎么做?
收藏本页到: 365Key | del.icio.us | | 添加到雅虎收藏+
  • 网站帮助 - 广告合作 - 网站地图