[Boost-bugs] [Boost C++ Libraries] #12271: segfaults in options_description with -fipa-pta

Subject: [Boost-bugs] [Boost C++ Libraries] #12271: segfaults in options_description with -fipa-pta
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-06-15 08:23:18


#12271: segfaults in options_description with -fipa-pta
------------------------------------------+-----------------------------
 Reporter: Seth <sshannin@…> | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
  Version: Boost 1.60.0 | Severity: Problem
 Keywords: segfault options_description |
------------------------------------------+-----------------------------
 With gcc-6.1.0, I'm seeing a lot of segfaults associated with
 boost::program_options::options_description. I had an older, but recent
 version of gcc lying around (5.3.0) that did not exhibit this behavior, so
 there's a decent chance that the fault lines in gcc itself vs. a newly
 exhibited bug here.

 If I make an empty one and just let it fall out of scope, I get a segfault
 from the destructor:
 {{{
 seth_at_luca:~$ cat example.cpp
 #include <boost/program_options.hpp>

 int main() {
     boost::program_options::options_description d;
     return 0;
 }
 seth_at_luca:~$ g++ -g3 example.cpp -llibboost_program_options -fipa-pta -o
 example
 seth_at_luca:~$ gdb ./example
 (gdb) r
 Starting program: /home/seth/./example
 Traceback (most recent call last):

 Program received signal SIGSEGV, Segmentation fault.
 0x00000000004026db in boost::detail::atomic_exchange_and_add
 (pw=0x200c5f2d8d48e02c, dv=-1)
     at
 /toolchain/toolchain9/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:50
 50 );
 (gdb) bt
 #0 0x00000000004026db in boost::detail::atomic_exchange_and_add
 (pw=0x200c5f2d8d48e02c, dv=-1)
     at
 /toolchain/toolchain9/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:50
 #1 0x0000000000402709 in boost::detail::sp_counted_base::release
 (this=0x200c5f2d8d48e024)
     at
 /toolchain/toolchain9/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:144
 #2 0x00000000004027a7 in boost::detail::shared_count::~shared_count
 (this=0x4033a8 <__libc_csu_init+8>, __in_chrg=<optimized out>)
     at
 /toolcain/toolchain9/include/boost/smart_ptr/detail/shared_count.hpp:473
 #3 0x0000000000402de0 in
 boost::shared_ptr<boost::program_options::options_description>::~shared_ptr
 (this=0x4033a0 <__libc_csu_init>,
     __in_chrg=<optimized out>) at
 /toolchain/toolchain9/include/boost/smart_ptr/shared_ptr.hpp:336
 #4 0x0000000000402dfb in
 std::_Destroy<boost::shared_ptr<boost::program_options::options_description>
> (__pointer=0x4033a0 <__libc_csu_init>)
     at /toolchain/toolchain9/include/c++/6.1.0/bits/stl_construct.h:93
 #5 0x0000000000402ce9 in
 std::_Destroy_aux<false>::__destroy<boost::shared_ptr<boost::program_options::options_description>*>
 (
     __first=0x4033a0 <__libc_csu_init>, __last=0x0) at
 /toolchain/toolchain9/include/c++/6.1.0/bits/stl_construct.h:103
 #6 0x0000000000402b98 in
 std::_Destroy<boost::shared_ptr<boost::program_options::options_description>*>
 (__first=0x4033a0 <__libc_csu_init>,
     __last=0x0) at
 /toolchain/toolchain9/include/c++/6.1.0/bits/stl_construct.h:126
 #7 0x0000000000402a23 in
 std::_Destroy<boost::shared_ptr<boost::program_options::options_description>*,
 boost::shared_ptr<boost::program_options::options_description> >
 (__first=0x4033a0 <__libc_csu_init>, __last=0x0) at
 /toolchain/toolchain9/include/c++/6.1.0/bits/stl_construct.h:151
 #8 0x000000000040288b in
 std::vector<boost::shared_ptr<boost::program_options::options_description>,
 std::allocator<boost::shared_ptr<boost::program_options::options_description>
> >::~vector (this=0x7fffffffdf58, __in_chrg=<optimized out>)
     at /toolchain/toolchain9/include/c++/6.1.0/bits/stl_vector.h:426
 #9 0x00000000004027c6 in
 boost::program_options::options_description::~options_description
 (this=0x7fffffffdef0, __in_chrg=<optimized out>)
     at
 /toolchain/toolchain9/include/boost/program_options/options_description.hpp:173
 #10 0x00000000004026b9 in main () at example.cpp:4
 }}}

 Alternatively, if I actually add any options, it segfaults during that:
 {{{
 seth_at_luca:~$ cat example2.cpp
 #include <boost/program_options.hpp>

 int main() {
     namespace po = boost::program_options;
     po::options_description d;

     int x = 0;
     d.add_options() ("xs,x", po::value(&x));
     return 0;
 }

 Program received signal SIGSEGV, Segmentation fault.
 0x000000000040dc66 in push_back (__x=<optimized out>, this=<optimized
 out>) at /toolchain/toolchain9/include/c++/6.1.0/bits/stl_bvector.h:89
 89 *_M_p &= ~_M_mask;
 (gdb) bt
 #0 0x000000000040dc66 in push_back (__x=<optimized out>, this=<optimized
 out>) at /toolchain/toolchain9/include/c++/6.1.0/bits/stl_bvector.h:89
 #1 add () at libs/program_options/src/options_description.cpp:288
 #2 boost::program_options::options_description_easy_init::operator()
 (this=0x4, name=0x7fffffffdee0 " \305\334\367\377\177", s=0x62ed80)
     at libs/program_options/src/options_description.cpp:246
 #3 0x0000000000403d78 in main () at example2.cpp:8
 }}}

 {{{
 seth_at_luca:~$ g++ --version
 g++ (GCC) 6.1.0
 Copyright (C) 2016 Free Software Foundation, Inc.
 }}}

 I'm linking statically against program_options.

 Let me know if there's any more information I can provide that would be
 helpful.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12271>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC