================================================================= ==5514==ERROR: AddressSanitizer: heap-use-after-free on address 0x621000006500 at pc 0x7fd764a7458d bp 0x7fff0b4c7d00 sp 0x7fff0b4c74a8 WRITE of size 24 at 0x621000006500 thread T0 #0 0x7fd764a7458c in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:790 #1 0x7fd76457e647 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x141647) #2 0x7fd7645709b3 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x1339b3) #3 0x5644733a870c in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) /usr/include/c++/9/ostream:570 #4 0x5644733a870c in taf::TC_Logger<taf::TimeWriteT, taf::TC_RollByTime>::stream(int) /root/taf/include/util/tc_logger.h:880 #5 0x5644733aac6f in taf::TC_Logger<taf::TimeWriteT, taf::TC_RollByTime>::log(int) /root/taf/include/util/tc_logger.h:792 #6 0x5644721b8a89 in EventMQHelper::terminate() /home/tafjce/和谐/和谐Server/EventMQHelper.h:1593 #7 0x5644721b79ab in EventMQHelper::~EventMQHelper() /home/tafjce/和谐/和谐Server/EventMQHelper.h:1533 #8 0x5644721b7b07 in EventMQHelper::~EventMQHelper() /home/tafjce/和谐/和谐Server/EventMQHelper.h:1534 #9 0x5644727cb1fa in taf::CreateUsingNew<EventMQHelper>::destroy(EventMQHelper*) (/data/app/taf/tafnode/data/和谐SZ.和谐Server/bin/和谐Server+0x21681fa) #10 0x5644726c0155 in taf::TC_Singleton<EventMQHelper, taf::CreateUsingNew, taf::DefaultLifetime>::destroySingleton() (/data/app/taf/tafnode/data/和谐SZ.和谐Server/bin/和谐Server+0x205d155) #11 0x7fd76412aa26 (/lib/x86_64-linux-gnu/libc.so.6+0x49a26) #12 0x7fd76412abdf in exit (/lib/x86_64-linux-gnu/libc.so.6+0x49bdf) #13 0x7fd7641080b9 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b9) #14 0x564470ac1edd in _start (/data/app/taf/tafnode/data/和谐SZ.和谐Server/bin/和谐Server+0x45eedd)
0x621000006500 is located 0 bytes inside of 4096-byte region [0x621000006500,0x621000007500) freed by thread T0 here: #0 0x7fd764ae96ef in operator delete[](void*) ../../../../src/libsanitizer/asan/asan_new_delete.cc:168 #1 0x564473d57bd3 in taf::LoggerBuffer::~LoggerBuffer() /root/taf/src/libutil/tc_logger.cpp:217 #2 0x7fd76412b43e in __call_tls_dtors (/lib/x86_64-linux-gnu/libc.so.6+0x4a43e)
previously allocated by thread T0 here: #0 0x7fd764ae8787 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:107 #1 0x564473d47789 in taf::LoggerBuffer::reserve(long) /root/taf/src/libutil/tc_logger.cpp:262 #2 0x564473d47789 in taf::LoggerBuffer::reserve(long) /root/taf/src/libutil/tc_logger.cpp:248 #3 0x564473d47a7a in taf::LoggerBuffer::overflow(int) /root/taf/src/libutil/tc_logger.cpp:288 #4 0x7fd76457e679 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x141679)
// Usage function inline SafeAppendFile& getFile(const string& filename){ // Static to use the same files and mutexes across calls static map<string, SafeAppendFile> files; static mutex mutex_; lock_guard<mutex> guard(mutex_); auto iter = files.find(filename); if (iter == files.end()) { // if file not exists files.emplace( piecewise_construct, forward_as_tuple(filename), forward_as_tuple(filename + "_" + to_string(TNOWMS))); iter = files.find(filename); } return iter->second; }
thread storage duration. The storage for
the object is allocated when the thread begins and deallocated when the
thread ends. Each thread has its own instance of the object. Only
objects declared thread_local have this storage duration. thread_local
can appear together with static or extern to adjust linkage. See non-local
variables and static
local variables for details on initialization of objects with this
storage duration.