Gdb 如何查看分段故障(堆芯转储)

Gdb 如何查看分段故障(堆芯转储),gdb,segmentation-fault,Gdb,Segmentation Fault,我无法继续看到核心被丢弃 我打字的时候有这个 gdb normal_estimation core Reading symbols from /home/sai/Documents/pcl_learning/normal_estimation/build/normal_estimation...(no debugging symbols found)...done. warning: core file may not match specified executable file. [N

我无法继续看到核心被丢弃

我打字的时候有这个

gdb normal_estimation core


Reading symbols from /home/sai/Documents/pcl_learning/normal_estimation/build/normal_estimation...(no debugging symbols found)...done.

warning: core file may not match specified executable file.
[New LWP 11816]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `./normal_estimation'.
Program terminated with signal 11, Segmentation fault.
#0  0xb53101d6 in free () from /lib/i386-linux-gnu/libc.so.6
(gdb) 
请让我知道我该怎么做

程序以信号11终止,分段故障。
#0 0xb53101d6在/lib/i386 linux gnu/libc.so.6的免费()中

您需要学习的第一个命令是
backtrace
(或其同义词:
where

这将告诉您哪个代码调用了已崩溃的
免费

但是,该代码可能与实际问题无关:
free
中的任何崩溃总是由某种类型的堆损坏引起的(释放未分配的内存、释放相同的内存两次、写入已释放的内存或溢出已分配的缓冲区)


在Linux上诊断堆损坏最有用的工具是和。很可能这些工具中的任何一个都会准确地告诉您做错了什么。

未找到调试符号
:这是一个提示。编译代码时启用调试(禁用优化也有助于调试)。如何给出调试符号不,您已经使用编译器(很可能是gcc)编译了代码。阅读它的文档以了解如何使用它。我使用了cmake,然后使用makecmake和make来调用编译器。您需要告诉他们如何为编译器传递适当的选项。由于您还没有提供有关makefile的任何信息,所以由您自己来决定。这是GDB报告。[使用libthread_db启用的线程调试]使用主机libthread_db库“/lib/i386 linux gnu/libthread_db.so.1”。核心是由“./正常_估计”生成的。程序以信号11终止,分段故障#在obstack.c:341 341 obstack.c:没有这样的文件或目录时,分配给obstack的0 0xb53101d6(h=0xb5498d18,obj=0xbfe6ca90)。(gdb)在obstack.c:341#1 0xbfe6cab0 in.处的bt#0 0xb53101d6 in.obstack(h=0xb5498d18,obj=0xbfe6ca90)分配??()#2 0x08087c5c在main()(gdb)我尝试了valgrind,它给出了这个总结。错误摘要:0个上下文中的0个错误(禁止:0个上下文中的0个)非法指令(内核转储)还有一件事…当我在web上看到时,所有程序都是使用g++或gcc编译的,但这里我有一个CMakeLists.txt,因此我做了cmake,然后做了。因此,我无法正确使用来自web的资源