Skip to content

Crash on ATS shutdown due to DbgCtl and order of global destruction #9261

Description

@cmcfarlen

When ATS exits, it can crash if a debug statement is encountered after the DbgCtl global registry Data is destructed. This happens in HostDBRecord::free (at least). Perhaps we can ensure that the registry is the last destructor called or otherwise avoid crashing on exit.

If I comment out HostDBRecord::free then it doesn't crash, but this is a general problem for order of destruction.

#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:853
#1  0x00007f3bde336f39 in DbgCtl::_RegistryAccessor::TagCmp::operator() (this=0x7f3bde430108 <DbgCtl::_RegistryAccessor::data()::d+40>, a=..., b=...) at /home/cmcfarlen/projects/oss/trafficserver/src/tscore/DbgCtl.cc:42
#2  0x00007f3bde336e3c in std::_Rb_tree<TSDbgCtl_s, TSDbgCtl_s, std::_Identity<TSDbgCtl_s>, DbgCtl::_RegistryAccessor::TagCmp, std::allocator<TSDbgCtl_s> >::_M_lower_bound (this=0x7f3bde430108 <DbgCtl::_RegistryAccessor::data()::d+40>,
    __x=0x7f3bdcd430f0, __y=0x7f3bde430110 <DbgCtl::_RegistryAccessor::data()::d+48>, __k=...) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:1951
#3  0x00007f3bde336d4e in std::_Rb_tree<TSDbgCtl_s, TSDbgCtl_s, std::_Identity<TSDbgCtl_s>, DbgCtl::_RegistryAccessor::TagCmp, std::allocator<TSDbgCtl_s> >::find (this=0x7f3bde430108 <DbgCtl::_RegistryAccessor::data()::d+40>, __k=...)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:2531
#4  0x00007f3bde33642d in std::set<TSDbgCtl_s, DbgCtl::_RegistryAccessor::TagCmp, std::allocator<TSDbgCtl_s> >::find (this=0x7f3bde430108 <DbgCtl::_RegistryAccessor::data()::d+40>, __x=...)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_set.h:795
#5  0x00007f3bde335f59 in DbgCtl::_get_ptr (tag=0x563f3fdba5f5 "hostdb") at /home/cmcfarlen/projects/oss/trafficserver/src/tscore/DbgCtl.cc:89
#6  0x0000563f3f8d25e1 in DbgCtl::DbgCtl (this=0x563f40068dd8 <HostDBRecord::free()::Debug_ctl>, tag=0x563f3fdba5f5 "hostdb") at /home/cmcfarlen/projects/oss/trafficserver/include/tscore/DbgCtl.h:36
#7  0x0000563f3fb98df8 in HostDBRecord::free (this=0x7f3bd9971f00) at /home/cmcfarlen/projects/oss/trafficserver/iocore/hostdb/HostDB.cc:2086
#8  0x0000563f3f9c41c3 in Ptr<HostDBRecord>::~Ptr (this=0x7f3bd98c75a8) at /home/cmcfarlen/projects/oss/trafficserver/include/tscore/Ptr.h:218
#9  0x0000563f3fbbf456 in HostFileRecord::~HostFileRecord (this=0x7f3bd98c75a8) at /home/cmcfarlen/projects/oss/trafficserver/iocore/hostdb/HostFile.h:33
#10 0x0000563f3fbbf429 in std::pair<ts::TextView const, HostFileRecord>::~pair (this=0x7f3bd98c7598) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_iterator.h:2547
#11 0x0000563f3fbbf409 in std::__new_allocator<std::__detail::_Hash_node<std::pair<ts::TextView const, HostFileRecord>, true> >::destroy<std::pair<ts::TextView const, HostFileRecord> > (this=0x7f3bd99490b8, __p=0x7f3bd98c7598)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/new_allocator.h:181
#12 0x0000563f3fbbf36d in std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<ts::TextView const, HostFileRecord>, true> > >::destroy<std::pair<ts::TextView const, HostFileRecord> > (__a=..., __p=0x7f3bd98c7598)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:535
#13 0x0000563f3fbbf33a in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<ts::TextView const, HostFileRecord>, true> > >::_M_deallocate_node (this=0x7f3bd99490b8, __n=0x7f3bd98c7590)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:1982
#14 0x0000563f3fbbf2f5 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<ts::TextView const, HostFileRecord>, true> > >::_M_deallocate_nodes (this=0x7f3bd99490b8, __n=0x7f3bd98c7560)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:2004
#15 0x0000563f3fbbf215 in std::_Hashtable<ts::TextView, std::pair<ts::TextView const, HostFileRecord>, std::allocator<std::pair<ts::TextView const, HostFileRecord> >, std::__detail::_Select1st, std::equal_to<ts::TextView>, std::hash<std::basic_string_view<char, std::char_traits<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::clear (
    this=0x7f3bd99490b8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h:2498
#16 0x0000563f3fbbf1a9 in std::_Hashtable<ts::TextView, std::pair<ts::TextView const, HostFileRecord>, std::allocator<std::pair<ts::TextView const, HostFileRecord> >, std::__detail::_Select1st, std::equal_to<ts::TextView>, std::hash<std::basic_string_view<char, std::char_traits<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable (
    this=0x7f3bd99490b8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h:1582
#17 0x0000563f3fbbeca5 in std::unordered_map<ts::TextView, HostFileRecord, std::hash<std::basic_string_view<char, std::char_traits<char> > >, std::equal_to<ts::TextView>, std::allocator<std::pair<ts::TextView const, HostFileRecord> > >::~unordered_map (this=0x7f3bd99490b8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unordered_map.h:102
#18 0x0000563f3fbbec6a in HostFile::~HostFile (this=0x7f3bd99490b0) at /home/cmcfarlen/projects/oss/trafficserver/iocore/hostdb/HostFile.h:38
#19 0x0000563f3fbbec35 in std::_Destroy<HostFile> (__pointer=0x7f3bd99490b0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:151
#20 0x0000563f3fbbebd9 in std::allocator_traits<std::allocator<void> >::destroy<HostFile> (__p=0x7f3bd99490b0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:648
#21 0x0000563f3fbbe7a6 in std::_Sp_counted_ptr_inplace<HostFile, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x7f3bd99490a0)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:613
#22 0x0000563f3f91411e in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x7f3bd99490a0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:346
#23 0x0000563f3f91409a in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x563f40067c98 <hostDB+8>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:1071
#24 0x0000563f3fb9ebd9 in std::__shared_ptr<HostFile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x563f40067c90 <hostDB>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr_base.h:1524
#25 0x0000563f3fb9b135 in std::shared_ptr<HostFile>::~shared_ptr (this=0x563f40067c90 <hostDB>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/shared_ptr.h:175
#26 0x0000563f3fb9b086 in HostDBCache::~HostDBCache (this=0x563f40067c90 <hostDB>) at /home/cmcfarlen/projects/oss/trafficserver/iocore/hostdb/P_HostDBProcessor.h:164
#27 0x00007f3bdd045495 in __run_exit_handlers (status=0, listp=0x7f3bdd219838 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:113
#28 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions