2015-10-05 114 views
0

我的應用程序在停止時遇到了崩潰。 GDB顯示下面的堆棧(應用程序是建立與-g -O0):線程的奇怪堆棧

(gdb) bt 
#0 0x0000000000000000 in ??() 
#1 0x00007f254ea99700 in ??() 
#2 0x0000000000000000 in ??() 

短調查顯示停止相應地開始以同樣的方式一個線程過程中崩潰發生許多其他的應用程序:

// mListener is std::thread and member of class UA 
std::thread thr(&UA::run, this); 
mListener = std::move(thr); 

然後我在停止之前在應用程序上運行gdb,並看到線程堆棧導致崩潰和其他線程之間的差異。 所有線程的樣子:

... 
#8 0x000000000043a70a in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (UI::Keyboard::*)()> (UI::Keyboard*)> >::_M_run() (this=0xa88fd0) 
    at /usr/include/c++/4.9/thread:115 
#9 0x00007fb6055c3970 in ??() from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 
#10 0x00007fb6083ff0a4 in start_thread (arg=0x7fb604042700) at pthread_create.c:309 
#11 0x00007fb604d3304d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

但「錯誤」的線程總是看起來不一樣:

#0 sem_wait() at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85 
#1 0x000000000043317d in Semaphore::wait (this=0x7fb5fc0009e8) at /home/vadius/workspace/iPhone/core/src/Core/env/Semaphore.h:28 
#2 0x0000000000432564 in SIP::UA::run (this=0x7fb5fc000980) at /home/vadius/workspace/iPhone/core/src/SIP/UA.cpp:132 
#3 0x0000000000000000 in ??() 

我認爲當工人從法(SIP::UA::run)線程退出它進入的代碼放在nullptr。 我的問題是: 1.我的權利和'壞'線程堆棧是錯誤的? 2.什麼可能是這種行爲的原因,以及如何避免它?

Debian的傑西X64/ GCC 4.9/ 編譯標誌:set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DDEBUG -g -O0")

+0

它看起來不對我。可能你的代碼已經損壞了它。 – torvin

回答

1

的贈品是 「地址」。 432564"C%d"。正常地址中的字節通常不是全部ASCII。這是一個堆棧緩衝區溢出。

+0

你是我的救助者。非常感謝你。 –