当前位置: 技术问答>linux和unix
程序出错,但不知道原因,各位看一下
来源: 互联网 发布时间:2015-09-06
本文导语: 我的程序在编译连接时都成功,但是运行时出现下面的错误,自己看不出原因,请高手指教 gdb调试,出错时返回的信息 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1076483584 (LWP 14132)] 0x4207414b in _int_m...
我的程序在编译连接时都成功,但是运行时出现下面的错误,自己看不出原因,请高手指教
gdb调试,出错时返回的信息
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076483584 (LWP 14132)]
0x4207414b in _int_malloc () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4207414b in _int_malloc () from /lib/tls/libc.so.6
#1 0x4207335b in malloc () from /lib/tls/libc.so.6
#2 0x40170e9e in operator new(unsigned) () from /usr/lib/libstdc++.so.5
#3 0x08050f07 in gather_if_info(char*, char*) (communityRead=0x8068b4c "public",
gateway=0xbffff7a0 "192.168.1.11") at gatherPerRouterInfo.cpp:454
#4 0x0805266b in GatherBridgeInfoAll(char*, char*) (communityRead=0x8068b4c "public",
machine=0xbffff7a0 "192.168.1.11") at gatherPerSwitchInfo.cpp:219
#5 0x0804ee1f in Layer2DiscoveryForEach() () at topologyDiscover.cpp:791
#6 0x0804f27c in Layer2Discovery() () at topologyDiscover.cpp:905
#7 0x0804a8d2 in main () at main.cpp:23
#8 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
gdb调试,出错时返回的信息
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076483584 (LWP 14132)]
0x4207414b in _int_malloc () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4207414b in _int_malloc () from /lib/tls/libc.so.6
#1 0x4207335b in malloc () from /lib/tls/libc.so.6
#2 0x40170e9e in operator new(unsigned) () from /usr/lib/libstdc++.so.5
#3 0x08050f07 in gather_if_info(char*, char*) (communityRead=0x8068b4c "public",
gateway=0xbffff7a0 "192.168.1.11") at gatherPerRouterInfo.cpp:454
#4 0x0805266b in GatherBridgeInfoAll(char*, char*) (communityRead=0x8068b4c "public",
machine=0xbffff7a0 "192.168.1.11") at gatherPerSwitchInfo.cpp:219
#5 0x0804ee1f in Layer2DiscoveryForEach() () at topologyDiscover.cpp:791
#6 0x0804f27c in Layer2Discovery() () at topologyDiscover.cpp:905
#7 0x0804a8d2 in main () at main.cpp:23
#8 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
|
malloc出错,可能你的内存已经被破坏,代码贴上来也没用。
查一下memcpy,strcpy等有没有写越界,或者指针指飞,可以用efence或者dmalloc相应的工具测一下。
查一下memcpy,strcpy等有没有写越界,或者指针指飞,可以用efence或者dmalloc相应的工具测一下。
|
能不能把你的程序源程序贴来一点。
上面的看得头大
上面的看得头大
|
#3 0x08050f07 in gather_if_info(char*, char*)
(communityRead=0x8068b4c "public",
gateway=0xbffff7a0 "192.168.1.11") at gatherPerRouterInfo.cpp:454
------------------------------------------------------------------------
好像是new的时候出的问题吧
(communityRead=0x8068b4c "public",
gateway=0xbffff7a0 "192.168.1.11") at gatherPerRouterInfo.cpp:454
------------------------------------------------------------------------
好像是new的时候出的问题吧
|
至少得有出错那几行的代码吧,不然不知道你怎么写的,没法判断啊。
不过我猜应该是指针没初始化或者指针不受控引起的吧。
不过我猜应该是指针没初始化或者指针不受控引起的吧。