I've written an application using threads from boost::thread. It compiles and works fine on my local machine. Problem occurs on the one of the servers. I've send main.cpp file and compiled it the same way I did on my local machine:
g++ -g main.cpp -o rdzen -lboost_thread
ulimit -c unlimited
I'm executing it with:
./rdzen input.txt dictionary.txt output.txt
then I got:
Segmentation fault (core dumped)
I used gdb to find out the reason:
gdb rdzen core
The backtrace is:
#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 is:
boost::thread watek1(boost::bind(&watek, 0, argv[1], argv[2], argv[3], 0));
What is the reason and why the same code works on my local machine and not on the server? Thanks in advance for help.