【发布时间】:2014-11-25 06:03:25
【问题描述】:
我有以下代码:
#include <cstdio>
#include <boost/thread.hpp>
void foo() {
puts("foo()");
}
int main() {
boost::thread t(foo);
//t.start_thread();
puts("join()");
t.join();
return 0;
}
它工作正常,但是当我取消注释 start_thread() 时,它会在 join() 中崩溃。
为什么start_thread() 调用会导致join() 中的分段错误?
我用:
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Boost 版本:1.54.0.1ubuntu1
g++ -std=c++11 -static main.cpp -lboost_thread -lboost_system -lpthread -L/usr/lib/x86_64-linux-gnu/
【问题讨论】:
-
SIGSEGV 并不是人们通常期望从如此成熟且广泛使用的库中获得的。
标签: c++ boost boost-thread