2011-10-12 60 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。我徹底刪除了它們,並安裝了最新的一個,問題就沒有了。