I faced with crash of my application when it stops. Gdb shows following stack (app is built with -g -O0):
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x00007f254ea99700 in ?? ()
#2 0x0000000000000000 in ?? ()
Short investigation has shown that crash happens during stopping a thread which is started the same way as many others in the app:
// mListener is std::thread and member of class UA
std::thread thr(&UA::run, this);
mListener = std::move(thr);
Then I ran gdb on app before stopping and saw the difference between stacks of thread caused crash and other threads. All threads looks like:
...
#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
But 'wrong' thread always looks different:
#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 ?? ()
I assume that when thread exits from worker method (SIP::UA::run) it goes to code placed in nullptr. My question is: 1. Am I right and stack of 'bad' thread is wrong? 2. What can be reason of such behavior and how to avoid it?
Debian jessie x64 / GCC 4.9 / Compile flags: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DDEBUG -g -O0")
Aucun commentaire:
Enregistrer un commentaire