現在boost::program_options
、BeagleBoard (ARM ベースのプロセッサ) で構成ファイルを解析するために使用しています。私のプログラムはマルチスレッドで、boost 1.45 multithreaded
ライブラリに対してリンクされています。
ただし、構成ファイルを解析するときにプログラムがハングするようです
namespace po = boost::program_options;
po::options_description desc("Options");
uint32_t option1=0;
std::vector<std::string> optionsString;
std::cout<<"Before adding options"<<std::endl;
desc.add_options()
("option1",
po::value<uint32_t>(&option1), "...")
("finaloption",
po::value<std::vector<std::string> >(&optionsString)->multitoken(), "string of options");
//Never gets here
std::cout<<"After adding options"<<std::endl;
po::variables_map vm;
std::cout<<"Starting program"<<std::endl;
「オプションの追加後」を出力する前に、プログラムがハングします。gdb を介してプログラムを実行すると、停止してバック トレースを実行すると、「Never gets here」コメントの前の行にあったことが示されます。バックトレースの上部にはそれがあります
#0 ??
#1 __lll_lock_wait lowlevellock.c:47
#2 __pthread_mutex_lock pthread_mutex_lock.c:61
#3 in boost::shared_ptr<boost::program_options::option_description>* std::__uninitialized_move_a<boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description>*, std::allocator<boost::shared_ptr<boost::program_option::option_description> > >(boost::shared_ptr<boost::program_optionns::option_description>*, boost::shared_ptr<boost::program_options::option_description>*, std::allocator<boost::shared_ptr<boost::program_options::option_description> >&) () from /usr/local/lib/libboost_program_options-mt.so.1.45.0
#4 in std::vector<boost::shared_ptr<boost::program_options::option_description>, std::allocator<boost::shared_ptr<boost::program_options::option_description> > >::_M_insert_aux(__gnu_cxx::__normal_iterator<boost::shared_ptr<boost::program_options::option_description>, std::vector<boost::shared_ptr<boost::program_options::option_description>, std::allocator<boost::shared_ptr<boost::program_options::option_description> const&)() from /usr/local/lib/libboost_program_options-mt.so.1.45.0
#5 in boost::program_options::options_description::add(boost::shared_ptr<boost::program_options::option_description>) () from /usr/local/lib/libboost_program_options-mt.so.1.45.0
...(もっと欲しい場合はお知らせください)
何かご意見は?このプログラムは x86 マシンで正常に動作します
編集: 詳細情報、これは最適化をオフにすると発生しないようです (-O2 でコンパイルすると、かなり一貫して発生します)。
Edit2: さらに分析すると、これは最適化がオフの -O0 でも発生することがわかります。