GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from a.out...done. [New LWP 22255] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". Core was generated by `./a.out'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x083e95b2 in WsddProxyImpl::discoverDevices (this=0xa617628, ip=0x0) at src/onvifwsddProxyImpl.cpp:131 131 matchDevice.Scopes = resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item; (gdb) bt #0 0x083e95b2 in WsddProxyImpl::discoverDevices (this=0xa617628, ip=0x0) at src/onvifwsddProxyImpl.cpp:131 #1 0x083b3d41 in OnvifClient::test (this=0xa5eb008, ip=0x0) at src/onvifClient.cpp:65 #2 0x083b3a0f in main_cpp (argc=1, argv=0xbfcc7ec4) at main.cpp:27 #3 0x083b39c8 in main (argc=1, argv=0xbfcc7ec4) at main.cpp:17
Program terminated with signal SIGSEGV, Segmentation fault. #0 0x083deb46 in DeviceBindingProxyImpl::getServices (this=0xa383ff8, services=...) at src/onvifDeviceBindingProxyImpl.cpp:68 68 services_[i].VersionMajor = resp.Service[i]->Version->Major; (gdb) bt #0 0x083deb46 in DeviceBindingProxyImpl::getServices (this=0xa383ff8, services=...) at src/onvifDeviceBindingProxyImpl.cpp:68 #1 0x083af56a in OnvifClient::test (this=0xa33a008, ip=0xbf88d91e "172.18.45.16") at onvifClient.cpp:101 #2 0x083af024 in main_cpp (argc=2, argv=0xbf88bdd4) at main.cpp:24 #3 0x083aefc4 in main (argc=2, argv=0xbf88bdd4) at main.cpp:10
代码片段:
1 2 3 4 5 6 7 8 9 10 11 12 13
for (unsigned int i = 0; i < resp.Service.size(); i++) { odt__Service tmp; tmp.Namespace = resp.Service[i]->Namespace; // 先给临时变量存储 tmp.XAddr = resp.Service[i]->XAddr; // 先给临时变量存储 if (resp.Service[i]->Version) { // 此处出现错误,在vector没有确定容器大小时,不能这样搞。。。 services_[i].VersionMajor = resp.Service[i]->Version->Major; services_[i].VersionMinor = resp.Service[i]->Version->Minor; } services_.push_back(tmp); // push_back,vector会自动增长 }