Momentan verwende ich boost::program_options
, um eine Konfigurationsdatei auf dem BeagleBoard (ARM-basierter Prozessor) zu parsen. Mein Programm ist multi-threaded und mit den boost 1.45 multithreaded
Bibliotheken verbunden.boost :: program_options hängt am arm "manchmal"
Mein Programm scheint nur zu hängen, wenn die Konfigurationsdatei Parsing obwohl
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;
Das Programm hängt vor dem Druck aus „Nach dem Hinzufügen von Optionen“. Wenn ich das Programm über gdb laufen lasse, höre es auf und mache eine Rückverfolgung, es zeigt nur an, dass es in der Zeile vor dem "Nie kommt hier" -Kommentar ist. Die Oberseite des Backtrace hat es gerade bei
#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
... (lassen Sie mich wissen, wenn Sie mehr wollen)
Irgendwelche Gedanken? Dieses Programm funktioniert gut auf einem x86-Rechner
Bearbeiten: Weitere Informationen, dies scheint nicht mit Optimierungen aus (kompiliert mit -O2 das wird ziemlich konsequent auftreten) passieren.
Edit2: Weitere Analyse zeigt, dass dies immer noch mit Optimierungen aus, -O0 passiert.
Können Sie zeigen, was Backtrace nach # 2 druckt? –
Warum hat es Platz in Optionsname? –
Schauen Sie, welcher Thread die Sperre hält und schauen Sie, was dieser Thread gerade macht. Möglicherweise haben Sie auch Ihre Sperre mit "Müll" überschrieben und/oder verwenden die nicht initialisierte Sperrstruktur. – PlasmaHH