id summary reporter owner description type status milestone component version severity resolution keywords cc 12017 Segfault with Boost program_options 1.60 debug libraries on OSX anonymous Vladimir Prus "Hi, I'm using Boost 1.60.0_1 (installed from Brew) and am trying to compile the following file: {{{ //mytest.cpp: #include #include namespace po = boost::program_options; int main(int argc, char *argv[]) { po::variables_map vm; po::options_description desc; desc.add_options() (""test,t"", po::value()->default_value(""something"")) ; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); return 0; } }}} I'm using CMake to compile. When compiling in Release mode, everything works fine. But when compiling in Debug mode, i get a segfault in the store() function when I run the program without the -t option: {{{ (lldb) bt * thread #1: tid = 0x5f2ad5, 0x000000010001b9c3 mytest`boost::program_options::value_semantic_codecvt_helper::parse(boost::any&, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&, bool) const [inlined] std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >::size(this=0xffffffffffffffd5 size=0) const at vector:653, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffd5) * frame #0: 0x000000010001b9c3 mytest`boost::program_options::value_semantic_codecvt_helper::parse(boost::any&, std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > > const&, bool) const [inlined] std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >::size(this=0xffffffffffffffd5 size=0) const at vector:653 frame #1: 0x000000010001b9c3 mytest`boost::program_options::value_semantic_codecvt_helper::parse(this=0x0000000100103740, value_store=0x00007fff5fbff408, new_tokens=size=0, utf8=) const + 51 at value_semantic.cpp:45 frame #2: 0x000000010001934d mytest`boost::program_options::store(options=0x00007fff5fbff5c8, xm=0x00007fff5fbff6c8, utf8=) + 1207 at variables_map.cpp:125 frame #3: 0x0000000100000cad mytest`main + 445 frame #4: 0x00007fff92a5e5ad libdyld.dylib`start + 1 }}} I noticed this happens only if the binary is linked with the static debug libraries, i.e libboost_program_options-d.a and libboost_program_options-mt-d.a. To reproduce without CMake: {{{ $ c++ mytest.cpp -I/usr/local/include /usr/local/lib/libboost_program_options-d.a -o mytest && ./mytest [1] 83707 segmentation fault ./mytest $ c++ mytest.cpp -DDEBUG -I/usr/local/include /usr/local/lib/libboost_program_options-d.a -o mytest && ./mytest [1] 83709 segmentation fault ./mytest }}} It crashes only when run without the -t argument; If I provide it, it works fine: {{{ $ ./mytest -t test }}} It does not crash when linked statically with a non-debug library: {{{ $ c++ mytest.cpp -DDEBUG -I/usr/local/include /usr/local/lib/libboost_program_options.a -o mytest && ./mytest $ c++ mytest.cpp -DDEBUG -I/usr/local/include /usr/local/lib/libboost_program_options-mt.a -o mytest && ./mytest }}} Or when linked dynamically with one of the shared libraries: {{{ $ c++ mytest.cpp -I/usr/local/include /usr/local/opt/boost/lib/libboost_program_options.dylib -o mytest && ./mytest $ c++ mytest.cpp -I/usr/local/include /usr/local/opt/boost/lib/libboost_program_options-mt.dylib -o mytest && ./mytest }}} The only workaround I found in order to compile a working debug binary with CMake is to use -DBoost_USE_STATIC_RUNTIME=ON because for some reason it tells the compiler to link with the shared library). " Bugs new To Be Determined program_options Boost 1.60.0 Problem