0

我使用 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));

是什么原因以及为什么相同的代码在我的本地机器上运行而不是在服务器上运行?提前感谢您的帮助。

4

0 回答 0