[2025-04-13 13-12-59] [DEBUG] [22204] [IOService.hpp] [141] - 进入设置上层处理函数
=================================================================
==22204==ERROR: AddressSanitizer: heap-use-after-free on address 0x511000000100 at pc 0x5934f277824f bp 0x7ffd85516c30 sp 0x7ffd85516c20
READ of size 8 at 0x511000000100 thread T0
#0 0x5934f277824e in std::_Function_base::_M_empty() const /usr/include/c++/13/bits/std_function.h:247
#1 0x5934f278a59f in std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)>::operator bool() const /usr/include/c++/13/bits/std_function.h:574
#2 0x5934f2782868 in IOServiceModule::IOService::recvData() /home/epsda/Codes_In_Linux/EpollServer_ET/IOService.hpp:66
#3 0x5934f277f51c in epollServerModule::EpollServer::loopOnce() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:78
#4 0x5934f277f76e in epollServerModule::EpollServer::startServer() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:97
#5 0x5934f2777531 in main /home/epsda/Codes_In_Linux/EpollServer_ET/main.cc:21
#6 0x7c6e95a2a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#7 0x7c6e95a2a28a in __libc_start_main_impl ../csu/libc-start.c:360
#8 0x5934f2775f74 in _start (/home/epsda/Codes_In_Linux/EpollServer_ET/main+0x6f74) (BuildId: f7d36700d4132470fb997f44c7b71a254a08564e)
0x511000000100 is located 192 bytes inside of 208-byte region [0x511000000040,0x511000000110)
freed by thread T0 here:
#0 0x7c6e962ff5e8 in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:164
#1 0x5934f2797ee3 in std::__new_allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::deallocate(std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>*, unsigned long) /usr/include/c++/13/bits/new_allocator.h:172
#2 0x5934f27959f8 in std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::deallocate(std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&, std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>*, unsigned long) /usr/include/c++/13/bits/alloc_traits.h:517
#3 0x5934f27959f8 in std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::~__allocated_ptr() /usr/include/c++/13/bits/allocated_ptr.h:74
#4 0x5934f2798f4a in std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_destroy() /usr/include/c++/13/bits/shared_ptr_base.h:623
#5 0x5934f277804d in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/include/c++/13/bits/shared_ptr_base.h:347
#6 0x5934f2786ce7 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/include/c++/13/bits/shared_ptr_base.h:1071
#7 0x5934f277e6e7 in std::__shared_ptr<connectionModule::Connection, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/include/c++/13/bits/shared_ptr_base.h:1524
#8 0x5934f277e707 in std::shared_ptr<connectionModule::Connection>::~shared_ptr() /usr/include/c++/13/bits/shared_ptr.h:175
#9 0x5934f277e72b in std::pair<int const, std::shared_ptr<connectionModule::Connection> >::~pair() /usr/include/c++/13/bits/stl_pair.h:187
#10 0x5934f2791e02 in void std::__new_allocator<std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false> >::destroy<std::pair<int const, std::shared_ptr<connectionModule::Connection> > >(std::pair<int const, std::shared_ptr<connectionModule::Connection> >*) /usr/include/c++/13/bits/new_allocator.h:198
#11 0x5934f2791e02 in void std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false> > >::destroy<std::pair<int const, std::shared_ptr<connectionModule::Connection> > >(std::allocator<std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false> >&, std::pair<int const, std::shared_ptr<connectionModule::Connection> >*) /usr/include/c++/13/bits/alloc_traits.h:558
#12 0x5934f2791e02 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false> > >::_M_deallocate_node(std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false>*) /usr/include/c++/13/bits/hashtable_policy.h:2011
#13 0x5934f2793244 in std::_Hashtable<int, std::pair<int const, std::shared_ptr<connectionModule::Connection> >, std::allocator<std::pair<int const, std::shared_ptr<connectionModule::Connection> > >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_erase(unsigned long, std::__detail::_Hash_node_base*, std::__detail::_Hash_node<std::pair<int const, std::shared_ptr<connectionModule::Connection> >, false>*) /usr/include/c++/13/bits/hashtable.h:2353
#14 0x5934f279027c in std::_Hashtable<int, std::pair<int const, std::shared_ptr<connectionModule::Connection> >, std::allocator<std::pair<int const, std::shared_ptr<connectionModule::Connection> > >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_erase(std::integral_constant<bool, true>, int const&) /usr/include/c++/13/bits/hashtable.h:2396
#15 0x5934f278d2c2 in std::_Hashtable<int, std::pair<int const, std::shared_ptr<connectionModule::Connection> >, std::allocator<std::pair<int const, std::shared_ptr<connectionModule::Connection> > >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::erase(int const&) /usr/include/c++/13/bits/hashtable.h:984
#16 0x5934f278a0d2 in std::unordered_map<int, std::shared_ptr<connectionModule::Connection>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::shared_ptr<connectionModule::Connection> > > >::erase(int const&) /usr/include/c++/13/bits/unordered_map.h:770
#17 0x5934f277fc47 in epollServerModule::EpollServer::popFdAndEventsFromConnections(int) /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:132
#18 0x5934f27842b7 in IOServiceModule::IOService::handleException() /home/epsda/Codes_In_Linux/EpollServer_ET/IOService.hpp:136
#19 0x5934f2782315 in IOServiceModule::IOService::recvData() /home/epsda/Codes_In_Linux/EpollServer_ET/IOService.hpp:40
#20 0x5934f277f51c in epollServerModule::EpollServer::loopOnce() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:78
#21 0x5934f277f76e in epollServerModule::EpollServer::startServer() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:97
#22 0x5934f2777531 in main /home/epsda/Codes_In_Linux/EpollServer_ET/main.cc:21
#23 0x7c6e95a2a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#24 0x7c6e95a2a28a in __libc_start_main_impl ../csu/libc-start.c:360
#25 0x5934f2775f74 in _start (/home/epsda/Codes_In_Linux/EpollServer_ET/main+0x6f74) (BuildId: f7d36700d4132470fb997f44c7b71a254a08564e)
previously allocated by thread T0 here:
#0 0x7c6e962fe548 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95
#1 0x5934f2797e8b in std::__new_allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/13/bits/new_allocator.h:151
#2 0x5934f2795941 in std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) /usr/include/c++/13/bits/alloc_traits.h:482
#3 0x5934f2795941 in std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<IOServiceModule::IOService, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&) /usr/include/c++/13/bits/allocated_ptr.h:98
#4 0x5934f27938ae in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<IOServiceModule::IOService, std::allocator<void>, std::shared_ptr<epollServerModule::EpollServer>&>(IOServiceModule::IOService*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<epollServerModule::EpollServer>&) /usr/include/c++/13/bits/shared_ptr_base.h:969
#5 0x5934f2790c79 in std::__shared_ptr<IOServiceModule::IOService, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, std::shared_ptr<epollServerModule::EpollServer>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<epollServerModule::EpollServer>&) /usr/include/c++/13/bits/shared_ptr_base.h:1712
#6 0x5934f278d9be in std::shared_ptr<IOServiceModule::IOService>::shared_ptr<std::allocator<void>, std::shared_ptr<epollServerModule::EpollServer>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<epollServerModule::EpollServer>&) /usr/include/c++/13/bits/shared_ptr.h:464
#7 0x5934f278ada5 in std::shared_ptr<std::enable_if<!std::is_array<IOServiceModule::IOService>::value, IOServiceModule::IOService>::type> std::make_shared<IOServiceModule::IOService, std::shared_ptr<epollServerModule::EpollServer>&>(std::shared_ptr<epollServerModule::EpollServer>&) /usr/include/c++/13/bits/shared_ptr.h:1010
#8 0x5934f2784f65 in listenerModule::Listener::recvData() /home/epsda/Codes_In_Linux/EpollServer_ET/Listener.hpp:49
#9 0x5934f277f51c in epollServerModule::EpollServer::loopOnce() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:78
#10 0x5934f277f76e in epollServerModule::EpollServer::startServer() /home/epsda/Codes_In_Linux/EpollServer_ET/EpollServer.hpp:97
#11 0x5934f2777531 in main /home/epsda/Codes_In_Linux/EpollServer_ET/main.cc:21
#12 0x7c6e95a2a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#13 0x7c6e95a2a28a in __libc_start_main_impl ../csu/libc-start.c:360
#14 0x5934f2775f74 in _start (/home/epsda/Codes_In_Linux/EpollServer_ET/main+0x6f74) (BuildId: f7d36700d4132470fb997f44c7b71a254a08564e)
SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/13/bits/std_function.h:247 in std::_Function_base::_M_empty() const
Shadow bytes around the buggy address:
0x510ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x510fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x510fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x511000000000: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
0x511000000080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x511000000100:[fd]fd fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x511000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x511000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x511000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x511000000300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x511000000380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==22204==ABORTING
根据上面的错误信息,首先看问题原因,即:AddressSanitizer: heap-use-after-free on address,可以得出结论:出现了野指针问题。接着看后面的内容可以得出问题出现在handleData_的位置出现了野指针问题
接着,再看第二部分freed by thread T0 here,这一行提示了指针是在何处进行的释放: