在Linux中调试段错误(core dumped)(4)

最后的结果gdb调试结果为:

[New LWP 5070] Core was generated by `8, 6238, 6768, 6414, 5857, 6219, 6774, 5642, 5099, 6080) (gdb) frame 0 #0 0x00007fa69aa8f17c in ___vsnprintf_chk (s=0x7ffcb1275ffa ", 5347"<error: Cannot access memory at address 0x7ffcb1276000>, maxlen=<optimized out>, flags=1, slen=<optimized out>, format=0x55e0aef3a657 ", %d", args=args@entry=0x7ffcb0e28c00) at vsnprintf_chk.c:66 66 in vsnprintf_chk.c (gdb) frame 1 #1 0x00007fa69aa8f095 in ___snprintf_chk (s=<optimized out>, maxlen=<optimized out>, flags=<optimized out>, slen=<optimized out>, format=<optimized out>) at snprintf_chk.c:34 34 snprintf_chk.c: No such file or directory. (gdb) frame 2 #2 0x000055e0aef2ee70 in writeResult(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >&, char*, int) () (gdb) frame 3 #3 0x000055e0aef35e5f in scheduling(std::vector<Vehicle, std::allocator<Vehicle> >&, std::vector<Road, std::allocator<Road> >&, std::vector<Cross, std::allocator<Cross> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) () (gdb) frame 4 #4 0x35202c3536303620 in ?? ()

以上结果说明在writeResult函数中出现了段错误.

利用thread apply all bt full查看每个线程在堆栈中的使用情况.

GDB过程中最重要的几个指令为:

0. gdb core-CodeCraft-2019.5070.jl.1554081713 1. set solib-absolute-prefix / 2. set solib-search-path / 3. file 可执行文件 4. core-file core-CodeCraft-2019.5070.jl.1554081713 5. frame 2

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/64ec0cd5759bfa40452f88e9f85fc868.html