簡體   English   中英

boost :: program_options“有時”掛在手臂上

[英]boost::program_options hangs on the arm “sometimes”

當前,我正在使用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運行該程序,請停止它並進行回溯,它僅表明該行在“永不到達這里”注釋之前。 回溯的頂部位於

#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仍然會發生這種情況。

這可能是與如何構建Boost和應用程序有關的問題。 如果您為拇指編譯而沒有拇指編譯,則互斥鎖的實現會有所不同。 確保使用相同的thumb設置編譯應用程序和boost庫。

這是我用來編譯boost的示例user-config.jam

if [ os.name ] = CYGWIN || [ os.name ] = NT
{
    HOST_TAG = windows ;
}
else if [ os.name ] = LINUX
{
    HOST_TAG = linux-x86 ;
}
else if [ os.name ] = MACOSX
{
    HOST_TAG = darwin-x86 ;
}

modules.poke : NO_BZIP2 : 1 ;
modules.poke : NO_GZIP : 1 ;

LIB_ROOT = /home/user/lib ;

NDK_ROOT = $(LIB_ROOT)/android-ndk-r8c ;

LLVM_VERSION = 3.1 ;
LLVM_NAME = llvm-$(LLVM_VERSION) ;
LLVM_TOOLCHAIN_ROOT = $(NDK_ROOT)/toolchains/$(LLVM_NAME) ;
LLVM_TOOLCHAIN_PREBUILT_ROOT = $(LLVM_TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) ;
LLVM_TOOLCHAIN_PREFIX = $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/ ;

TOOLCHAIN_VERSION = 4.6 ;
TOOLCHAIN_NAME = arm-linux-androideabi-$(TOOLCHAIN_VERSION) ;
TOOLCHAIN_ROOT = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME) ;
TOOLCHAIN_PREBUILT_ROOT = $(TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) ;
TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi- ;

using clang : $(TOOLCHAIN_VERSION) :
$(LLVM_TOOLCHAIN_PREFIX)clang :
<compileflags>"-gcc-toolchain $(TOOLCHAIN_PREBUILT_ROOT)"
<compileflags>"-isystem $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/lib/clang/$(LLVM_VERSION)/include"
<compileflags>"-isysroot $(NDK_ROOT)/platforms/android-9/arch-arm/usr/include"
<compileflags>-std=gnu++11
<compileflags>-stdlib=libc++
<compileflags>-fomit-frame-pointer
<compileflags>-ffast-math
<compileflags>"-target armv7-none-linux-androideabi"
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=neon
<compileflags>-DPAGE_SIZE=sysconf\\(_SC_PAGESIZE\\)
<compileflags>-I$(NDK_ROOT)/boost/include
<compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
<compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs//armeabi-v7a/include
<compileflags>-I$(NDK_ROOT)/platforms/android-9/arch-arm/usr/include
<linkflags>-s
<archiver>$(TOOLCHAIN_PREFIX)ar
<ranlib>$(TOOLCHAIN_PREFIX)ranlib
;

請注意,在此示例中,我沒有在啟用Thumb的情況下進行編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM