我使用boost :: thread中的线程编写了一个应用程序。它在我的本地机器上编译并正常工作。其中一台服务器出现问题。我发送main.cpp文件并按照我在本地机器上的方式编译它:
g++ -g main.cpp -o rdzen -lboost_thread
ulimit -c unlimited
我正在执行它:
./rdzen input.txt dictionary.txt output.txt
然后我得到了:
Segmentation fault (core dumped)
我用gdb找出原因:
gdb rdzen core
回溯是:
#0 0x0804c039 in boost::detail::atomic_exchange_and_add (pw=0x53006d76, dv=-1)
at /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:50
#1 0x0804c11a in boost::detail::sp_counted_base::release (this=0x53006d72)
at /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:143
#2 0x0804c17c in ~shared_count (this=0xbd928a8c, __in_chrg=<value optimized out>)
at /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:305
#3 0xb2b388e1 in ~shared_ptr (this=0xbd928b3c) at ./boost/smart_ptr/shared_ptr.hpp:169
#4 boost::shared_ptr<boost::detail::thread_data_base>::operator= (this=0xbd928b3c)
at ./boost/smart_ptr/shared_ptr.hpp:305
#5 boost::thread::start_thread (this=0xbd928b3c) at libs/thread/src/pthread/thread.cpp:184
#6 0x0805022c in thread<boost::_bi::bind_t<void, void (*)(int, char*, char*, char*, int), boost::_bi::list5<boost::_bi::value<int>, boost::_bi::value<char*>, boost::_bi::value<char*>, boost::_bi::value<char*>, boost::_bi::value<int> > > > (this=0xbd928b3c, f=...)
at /usr/local/include/boost/thread/detail/thread.hpp:205
#7 0x0804a88a in main (argc=4, argv=0xbd928cb4) at main.cpp:542
main.cpp:542是:
boost::thread watek1(boost::bind(&watek, 0, argv[1], argv[2], argv[3], 0));
为什么相同的代码在我的本地计算机上而不是在服务器上运行的原因是什么?在此先感谢您的帮助。