簡體   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