[Boost-bugs] [Boost C++ Libraries] #13259: seg fault at cleanup time, __run_exit_handlers

Subject: [Boost-bugs] [Boost C++ Libraries] #13259: seg fault at cleanup time, __run_exit_handlers
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-10-12 12:00:35


#13259: seg fault at cleanup time, __run_exit_handlers
-------------------------------------+---------------------------
 Reporter: James E. King, III | Owner: Robert Ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------+---------------------------
 I am getting a segfault at __run_exit_handlers time with 1.66 develop
 commit id d21a064a69663faf106ea363bf4785904bfd44d1 (Oct 6) using build
 command

 {{{~/boost/libs/serialization/test$ ../../../b2 toolset=clang
 test_dll_exported -q}}}:

 {{{
 ==13247== Invalid free() / delete / delete[] / realloc()
 ==13247== at 0x4C2F25B: operator delete(void*) (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==13247== by 0x50A097F:
 __gnu_cxx::new_allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::deallocate(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*, unsigned long) (new_allocator.h:110)
 ==13247== by 0x50A092F:
 __gnu_cxx::__alloc_traits<std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >
>::deallocate(std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >&,
 std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*, unsigned long) (alloc_traits.h:133)
 ==13247== by 0x50A07CB:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_put_node(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*) (stl_tree.h:509)
 ==13247== by 0x50A071B:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_drop_node(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*) (stl_tree.h:576)
 ==13247== by 0x50A127B:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_erase_aux(std::_Rb_tree_const_iterator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>) (stl_tree.h:2275)
 ==13247== by 0x50A1234:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::erase(std::_Rb_tree_const_iterator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>) (stl_tree.h:1057)
 ==13247== by 0x509FF64:
 std::multiset<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::erase(std::_Rb_tree_const_iterator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>) (stl_multiset.h:571)
 ==13247== by 0x509FB97:
 boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()
 (extended_type_info_typeid.cpp:108)
 ==13247== by 0x4205E4:
 boost::serialization::extended_type_info_typeid<polymorphic_derived2>::~extended_type_info_typeid()
 (extended_type_info_typeid.hpp:96)
 ==13247== by 0x420134:
 boost::serialization::singleton<boost::serialization::extended_type_info_typeid<polymorphic_derived2>
>::get_instance()::singleton_wrapper::~singleton_wrapper()
 (singleton.hpp:117)
 ==13247== by 0x601B26F: __run_exit_handlers (exit.c:83)
 ==13247== Address 0x63b9d80 is 0 bytes inside a block of size 40 free'd
 ==13247== at 0x4C2F25B: operator delete(void*) (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==13247== by 0x50A097F:
 __gnu_cxx::new_allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::deallocate(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*, unsigned long) (new_allocator.h:110)
 ==13247== by 0x50A092F:
 __gnu_cxx::__alloc_traits<std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >
>::deallocate(std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >&,
 std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*, unsigned long) (alloc_traits.h:133)
 ==13247== by 0x50A07CB:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_put_node(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*) (stl_tree.h:509)
 ==13247== by 0x50A071B:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_drop_node(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*) (stl_tree.h:576)
 ==13247== by 0x50A0647:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_erase(std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*) (stl_tree.h:1640)
 ==13247== by 0x50A05BE:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::~_Rb_tree() (stl_tree.h:873)
 ==13247== by 0x50A0584:
 std::multiset<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::~multiset() (stl_multiset.h:92)
 ==13247== by 0x50A0414:
 boost::serialization::singleton<std::multiset<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> > >::get_instance()::singleton_wrapper::~singleton_wrapper()
 (singleton.hpp:117)
 ==13247== by 0x601B5E9: __cxa_finalize (cxa_finalize.c:56)
 ==13247== by 0x5087F12: ??? (in
 /home/jking/boost/bin.v2/libs/serialization/build/clang-gnu-
 linux-4.0.0/debug/threadapi-pthread/libboost_serialization.so.1.66.0)
 ==13247== by 0x4011109: _dl_fini (dl-fini.c:235)
 ==13247== Block was alloc'd at
 ==13247== at 0x4C2E19F: operator new(unsigned long) (in
 /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==13247== by 0x50A0FC0:
 __gnu_cxx::new_allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::allocate(unsigned long, void const*) (new_allocator.h:104)
 ==13247== by 0x50A0F6B:
 __gnu_cxx::__alloc_traits<std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >
>::allocate(std::allocator<std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >&, unsigned long) (alloc_traits.h:130)
 ==13247== by 0x50A0E43:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::_M_get_node() (stl_tree.h:505)
 ==13247== by 0x50A0DFF:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_create_node(boost::serialization::typeid_system::extended_type_info_typeid_0
 const* const&) (stl_tree.h:527)
 ==13247== by 0x50A0D8F:
 std::_Rb_tree_node<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>*
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_Alloc_node::operator()<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>(boost::serialization::typeid_system::extended_type_info_typeid_0
 const* const&) const (stl_tree.h:473)
 ==13247== by 0x50A0BDB:
 std::_Rb_tree_iterator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_insert_<std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::_Alloc_node>(std::_Rb_tree_node_base*,
 std::_Rb_tree_node_base*,
 boost::serialization::typeid_system::extended_type_info_typeid_0 const*
 const&,
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*> >::_Alloc_node&) (stl_tree.h:1535)
 ==13247== by 0x50A09FC:
 std::_Rb_tree<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::extended_type_info_typeid_0
 const*,
 std::_Identity<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::_M_insert_equal(boost::serialization::typeid_system::extended_type_info_typeid_0
 const* const&) (stl_tree.h:1918)
 ==13247== by 0x509FE2C:
 std::multiset<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*, boost::serialization::typeid_system::type_compare,
 std::allocator<boost::serialization::typeid_system::extended_type_info_typeid_0
 const*>
>::insert(boost::serialization::typeid_system::extended_type_info_typeid_0
 const* const&) (stl_multiset.h:474)
 ==13247== by 0x509FA68:
 boost::serialization::typeid_system::extended_type_info_typeid_0::type_register(std::type_info
 const&) (extended_type_info_typeid.cpp:91)
 ==13247== by 0x4201CA:
 boost::serialization::extended_type_info_typeid<polymorphic_derived2>::extended_type_info_typeid()
 (extended_type_info_typeid.hpp:91)
 ==13247== by 0x4200FE:
 boost::serialization::singleton<boost::serialization::extended_type_info_typeid<polymorphic_derived2>
>::get_instance()::singleton_wrapper::singleton_wrapper()
 (singleton.hpp:117)
 }}}

 In gdb it looks like this, not sure if it's the same thing however:

 {{{
 (gdb) r
 Starting program:
 /home/jking/boost/bin.v2/libs/serialization/test/test_dll_exported.test
 /clang-gnu-linux-4.0.0/debug/threadapi-pthread/test_dll_exported
 No errors detected.

 Program received signal SIGSEGV, Segmentation fault.
 0x00007ffff71f79b6 in
 std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*,
 std::_Rb_tree_node_base&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
 (gdb) bt
 #0 0x00007ffff71f79b6 in
 std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*,
 std::_Rb_tree_node_base&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
 #1 0x00007ffff793564b in
 std::_Rb_tree<boost::serialization::extended_type_info const*,
 boost::serialization::extended_type_info const*,
 std::_Identity<boost::serialization::extended_type_info const*>,
 boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*>
>::_M_erase_aux (
     this=0x7ffff7b9e948
 <boost::serialization::singleton<std::multiset<boost::serialization::extended_type_info
 const*, boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*> >
>::get_instance()::t>, __position=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>)
     at /usr/bin/../lib/gcc/x86_64-linux-
 gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_tree.h:2272
 #2 0x00007ffff7935615 in
 std::_Rb_tree<boost::serialization::extended_type_info const*,
 boost::serialization::extended_type_info const*,
 std::_Identity<boost::serialization::extended_type_info const*>,
 boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*> >::erase (
     this=0x7ffff7b9e948
 <boost::serialization::singleton<std::multiset<boost::serialization::extended_type_info
 const*, boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*> >
>::get_instance()::t>, __position=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>)
     at /usr/bin/../lib/gcc/x86_64-linux-
 gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_tree.h:1057
 #3 0x00007ffff7934395 in
 std::multiset<boost::serialization::extended_type_info const*,
 boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*> >::erase (
     this=0x7ffff7b9e948
 <boost::serialization::singleton<std::multiset<boost::serialization::extended_type_info
 const*, boost::serialization::detail::key_compare,
 std::allocator<boost::serialization::extended_type_info const*> >
>::get_instance()::t>, __position=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>)
     at /usr/bin/../lib/gcc/x86_64-linux-
 gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_multiset.h:571
 #4 0x00007ffff7933ec9 in
 boost::serialization::extended_type_info::key_unregister (this=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>)
     at ../../../libs/serialization/src/extended_type_info.cpp:136
 #5 0x000000000041fed7 in
 boost::serialization::extended_type_info_no_rtti<polymorphic_base>::~extended_type_info_no_rtti
 (
     this=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>) at
 ../../../boost/serialization/extended_type_info_no_rtti.hpp:107
 #6 0x000000000041fa05 in
 boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::singleton_wrapper::~singleton_wrapper() (
     this=0x631870
 <boost::serialization::singleton<boost::serialization::extended_type_info_no_rtti<polymorphic_base>
>::get_instance()::t>) at ../../../boost/serialization/singleton.hpp:117
 #7 0x00007ffff68a3270 in __run_exit_handlers (status=0,
 listp=0x7ffff6c2a5d8 <__exit_funcs>,
 run_list_atexit=run_list_atexit_at_entry=true,
 run_dtors=run_dtors_at_entry=true) at exit.c:83
 #8 0x00007ffff68a32ca in __GI_exit (status=<optimized out>) at exit.c:105
 #9 0x00007ffff68893f8 in __libc_start_main (main=0x414660 <main(int,
 char**)>, argc=1, argv=0x7fffffffe2e8, init=<optimized out>,
 fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe2d8)
 at ../csu/libc-start.c:325
 #10 0x00000000004143ca in _start () at
 ../../../boost/serialization/singleton.hpp:155
 }}}

 I don't think either of these issues specifically describes the memory
 leak in #13186 (valgrind is reporting that too) which is why I am opening
 a new defect for it.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13259>
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-10-12 12:08:09 UTC