【发布时间】:2015-02-11 19:37:52
【问题描述】:
我希望 gdb 仅显示我的代码(跳过包含的标头)。我正在努力解决我的多线程程序随机抛出的分段错误。在 gdb 中我可以看到:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffeffff700 (LWP 27533)]
0x0000000000409939 in std::thread::joinable (this=0x0) at /usr/include/c++/4.9.2/thread:162
162 { return !(_M_id == id()); }
(gdb) bt
#0 0x0000000000409939 in std::thread::joinable (this=0x0) at /usr/include/c++/4.9.2/thread:162
#1 0x0000000000404562 in Finder::join_threads (this=0x7ffff0000cd0) at global_search.cpp:25
#2 0x0000000000416ea9 in std::_Mem_fn<void (Finder::*)()>::operator()<, void>(Finder&) const (this=0x7ffff00013c0, __object=...) at /usr/include/c++/4.9.2/functional:556
#3 0x0000000000416d1e in std::_Mem_fn<void (Finder::*)()>::operator()<Finder<>, void>(std::reference_wrapper<Finder<> >, (void&&)...) const (this=0x7ffff00013c0, __ref=...)
at /usr/include/c++/4.9.2/functional:585
#4 0x00000000004166fe in std::_Bind_simple<std::_Mem_fn<void (Finder::*)()> (std::reference_wrapper<Finder>)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x7ffff00013b8)
at /usr/include/c++/4.9.2/functional:1700
#5 0x00000000004160eb in std::_Bind_simple<std::_Mem_fn<void (Finder::*)()> (std::reference_wrapper<Finder>)>::operator()() (this=0x7ffff00013b8)
at /usr/include/c++/4.9.2/functional:1688
#6 0x0000000000415b12 in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (Finder::*)()> (std::reference_wrapper<Finder>)> >::_M_run() (this=0x7ffff00013a0)
at /usr/include/c++/4.9.2/thread:115
#7 0x00007ffff76b4d90 in execute_native_thread_routine () from /usr/lib/libstdc++.so.6
#8 0x00007ffff7910374 in start_thread () from /usr/lib/libpthread.so.0
#9 0x00007ffff6e2427d in clone () from /usr/lib/libc.so.6
在我的代码中(不是在线程库中)发生错误的时间点是什么?或者至少是对 thread::joinable() 函数的哪个调用导致了错误?有可能得到这样的信息吗?很抱歉提出这样的问题,但我对使用 gdb 进行调试完全不熟悉。
【问题讨论】:
标签: multithreading debugging segmentation-fault gdb