繁体   English   中英

使用Gdb调试器,我应该如何找出“程序终止于信号11,分段错误”的原因。

[英]Using Gdb debugger, how should I proceed to find out the cause of “Program terminated with signal 11, Segmentation fault.”

这是gdb的回溯,

Program terminated with signal 11, Segmentation fault.
#0  0xb7e78830 in Gtk::Widget::get_width () from /usr/lib/libgtkmm-2.4.so.1
(gdb) bt
#0  0xb7e78830 in Gtk::Widget::get_width () from /usr/lib/libgtkmm-2.4.so.1
#1  0x08221d5d in sigc::bound_mem_functor0<bool, videoScreen>::operator() (this=0xb1c04714)
    at /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1787`enter code here`
#2  0x08221d76 in sigc::adaptor_functor<sigc::bound_mem_functor0<bool, videoScreen> >::operator() (this=0xb1c04710)
    at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251
#3  0x08221d96 in sigc::internal::slot_call0<sigc::bound_mem_functor0<bool, videoScreen>, bool>::call_it (rep=0xb1c046f8)
    at /usr/include/sigc++-2.0/sigc++/functors/slot.h:103
#4  0xb7b1ed35 in ?? () from /usr/lib/libglibmm-2.4.so.1
#5  0xb73c6bb6 in ?? () from /usr/lib/libglib-2.0.so.0
#6  0xb28ff1f8 in ?? ()
#7  0xb647479c in __pthread_mutex_unlock_usercnt () from /lib/libpthread.so.0
#8  0xb73c6446 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#9  0xb73c97e2 in ?? () from /usr/lib/libglib-2.0.so.0
#10 0xb3d11af8 in ?? ()
#11 0x00000000 in ?? ()

我想出了崩溃的行,这是该行的代码。

1:currPicLoaded = 1;
2:int status = -1;
3:zoomedPicWidth = drawVideo1->get_width();    

我发现上面的3行是导致崩溃的原因,但是此行在崩溃之前执行了5次,所以我不知道为什么它在第6次崩溃。 PS:上面的代码行带有一个连续运行的线程。

任何帮助都超过了欢迎:)

我应该如何进行

您的第一步应该是找出导致SIGSEGV指令。 做这个:

 (gdb) x/i $pc

最可能的原因是您的drawVideo1对象悬空(已删除)或以其他方式损坏。

由于您显然在Linux上(您没有说,但您应该始终说),因此用于调试此类“奇怪”问题的第一个工具是Valgrind

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM