uvletter commented on issue #2416: URL: https://github.com/apache/brpc/issues/2416#issuecomment-1964383015
Thx, my current workaround is compiling brpc with std=c++17 too. Just wanna report the unworkable cacheline alignment and underlying risk in mixed compilation units. 获取 Outlook for iOS<https://aka.ms/o0ukef> ________________________________ 发件人: Dongsheng He ***@***.***> 发送时间: Monday, February 26, 2024 10:56:16 PM 收件人: apache/brpc ***@***.***> 抄送: Tian ***@***.***>; Comment ***@***.***> 主题: Re: [apache/brpc] struct/class that require cacheline alignment may not work when using new (before c++17). (Issue #2416) ================================================================= ==155368==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x621000030d00 in thread T22 (brpc_timer): object passed to delete has wrong type: size of the allocated type: 4096 bytes; size of the deallocated type: 4096 bytes. alignment of the allocated type: default-aligned; alignment of the deallocated type: 64 bytes. #0 0x7ff6e41a35d5 in operator delete(void*, unsigned long, std::align_val_t) (/usr/lib64/libasan.so.5+0x1105d5) #1 0x752bc9 in bvar::detail::AgentGroup<bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::Agent>::_destroy_tls_blocks() external/com_github_apache_brpc/src/bvar/detail/agent_group.h:166 #2 0x752bc9 in bvar::detail::AgentGroup<bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::Agent>::_destroy_tls_blocks() external/com_github_apache_brpc/src/bvar/detail/agent_group.h:161 #3 0x150d34f in butil::detail::ThreadExitHelper::~ThreadExitHelper() external/com_github_apache_brpc/src/butil/thread_local.cpp:41 #4 0x150d34f in delete_thread_exit_helper external/com_github_apache_brpc/src/butil/thread_local.cpp:77 #5 0x150d34f in delete_thread_exit_helper external/com_github_apache_brpc/src/butil/thread_local.cpp:76 #6 0x7ff6e3c68ca1 in __nptl_deallocate_tsd /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:155 #7 0x7ff6e3c68eb2 in start_thread /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:314 #8 0x7ff6e2690b0c in clone (/lib64/libc.so.6+0xfeb0c) 0x621000030d00 is located 0 bytes inside of 4096-byte region [0x621000030d00,0x621000031d00) allocated by thread T22 (brpc_timer) here: #0 0x7ff6e41a1767 in operator new(unsigned long, std::nothrow_t const&) (/usr/lib64/libasan.so.5+0x10e767) #1 0x1227afe in bvar::detail::AgentGroup<bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::Agent>::get_or_create_tls_agent(int) external/com_github_apache_brpc/src/bvar/detail/agent_group.h:150 #2 0x1227afe in bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::get_or_create_tls_agent() external/com_github_apache_brpc/src/bvar/detail/combiner.h:297 #3 0x1227afe in bvar::Reducer<long, bvar::detail::AddTo<long>, bvar::detail::MinusFrom<long> >::operator<<(long) external/com_github_apache_brpc/src/bvar/reducer.h:194 #4 0x1227afe in int bthread::TaskGroup::start_background<true>(unsigned long*, bthread_attr_t const*, void* (*)(void*), void*) external/com_github_apache_brpc/src/bthread/task_group.cpp:453 #5 0x11fa28f in bthread::start_from_non_worker(unsigned long*, bthread_attr_t const*, void* (*)(void*), void*) external/com_github_apache_brpc/src/bthread/bthread.cpp:150 #6 0x11fa28f in bthread_start_background external/com_github_apache_brpc/src/bthread/bthread.cpp:230 #7 0xaac90d in braft::RepeatedTimerTask::on_timedout(void*) external/com_meituan_mraft/src/braft/repeated_timer_task.cpp:120 #8 0x1200a04 in bthread::TimerThread::Task::run_and_delete() external/com_github_apache_brpc/src/bthread/timer_thread.cpp:282 #9 0x1202fb5 in bthread::TimerThread::run() external/com_github_apache_brpc/src/bthread/timer_thread.cpp:395 #10 0x12075ef in bthread::TimerThread::run_this(void*) external/com_github_apache_brpc/src/bthread/timer_thread.cpp:122 #11 0x7ff6e3c68ea4 in start_thread /usr/src/debug/glibc-2.17-c758a686/nptl/pthread_create.c:307 I met the same problem. I compile my project in C++17, while the compilation option for BRPC is C++11, so ASAN detects the dismatch between new and delete. #2421<https://github.com/apache/brpc/pull/2421> Try this fix. ― Reply to this email directly, view it on GitHub<https://github.com/apache/brpc/issues/2416#issuecomment-1964341023>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEMHU7GMT5HWBZ4A7IDOXYTYVSPBBAVCNFSM6AAAAAA6GV4RTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGM2DCMBSGM>. You are receiving this because you commented.Message ID: ***@***.***> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org