2011-10-12 58 views
0

我试图编译并在Ubuntu 10.10升压HTTP服务器实例崩溃时的boost ::在Ubuntu 10.10线程

http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/http/server3/

运行下面的例子,但它崩溃的:

// Create a pool of threads to run all of the io_services. 

std::vector<boost::shared_ptr<boost::thread> > threads; 
for (std::size_t i = 0; i < thread_pool_size_; ++i) 
{ 
    boost::shared_ptr<boost::thread> thread(new boost::thread(
      boost::bind(&boost::asio::io_service::run, &io_service_))); 
    threads.push_back(thread); 
} 

调用堆栈:

Thread [1] 573 [core: 0] (Suspended : Signal : SIGSEGV:Segmentation fault) 
    boost::thread::start_thread() at 0x8064a64 
    boost::thread::thread<boost::_bi::bind_t<unsigned int, boost::_mfi::mf0<unsigned int, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >() at thread.hpp:204 0x805e8c6 
    http::server3::server::run() at server.cpp:57 0x8059cbf 
    main() at HttpServer3.cpp:38 0x8048522 

但是,它不会崩溃在Ubuntu 11.04,出于同样的ECL ipse CDT项目。

有什么建议吗?

+0

我最初的猜测是Boost.Thread在10.10安装中没有正确构建。 – ildjarn

+0

我在10.10上成功构建了boost lib。有趣的是在11.04,我确实遇到了一些错误,但它可以正常工作。 –

+0

你可能是对的。看到我自己的答案。 –

回答

0

看来ildjarn的初步猜测可能是正确的。

我发现在我的Ubuntu 10.10上有两个版本的boost lib。我彻底删除了它们,并安装了最新的一个,问题就没有了。