libhv icon indicating copy to clipboard operation
libhv copied to clipboard

in version 1.3.1, any data race warnings reported in runtime when compile with "-fsanitize=thread -fsanitize-recover=all"

Open monk1magic opened this issue 2 years ago • 0 comments

I compile the websocket server and client sample with the flag "-fsanitize=thread -fsanitize-recover=all", when start them, there will report any data race warning by sanitizer(https://github.com/google/sanitizers/wiki/), some likes below :

================== WARNING: ThreadSanitizer: data race (pid=13948) Write of size 8 at 0x7b38000000f8 by main thread: #0 hv::EventLoop::stop() (worker+0xa2be0) #1 hv::EventLoopThread::stop(bool) (worker+0xa34be) #2 hv::TcpClientTmplhv::WebSocketChannel::stop(bool) (worker+0xabad1) #3 main ******/enter.cpp:266 (worker+0xa0527)

Previous read of size 8 at 0x7b38000000f8 by thread T2: #0 hv::EventLoop::tid() (worker+0xa2c70) #1 hv::EventLoop::generateTimerID() (libhv.so+0x1c4f58) #2 hv::Channel::on_close(hio_s*) /home/user/work/install/libhv-1.3.1/evpp/Channel.h:221 (libhv.so+0x1c2529)

As if synchronized via sleep: #0 nanosleep ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:366 (libtsan.so.0+0x6696c) #1 void std::this_thread::sleep_for<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> > const&) /usr/include/c++/11/bits/this_thread_sleep.h:82 (worker+0xa842b) #2 main ******/enter.cpp:260 (worker+0xa0462)

Location is heap block of size 216 at 0x7b38000000e0 allocated by main thread: #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162) #1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<hv::EventLoop, std::allocatorhv::EventLoop, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/11/ext/new_allocator.h:127 (libhv.so+0x1f4ff5) #2 main ******/enter.cpp:127 (worker+0x9f3bb)

Thread T2 (tid=13958, finished) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_deletestd::thread::_State >, void (*)()) (libstdc++.so.6+0xdc328) #2 main ******/enter.cpp:185 (worker+0x9ff62)

SUMMARY: ThreadSanitizer: data race (******/worker+0xa2be0) in hv::EventLoop::stop()

================== WARNING: ThreadSanitizer: data race (pid=13947) Write of size 8 at 0x7b38000000f8 by main thread: #0 hv::EventLoop::stop() (worker+0xa2be0) #1 hv::EventLoopThread::stop(bool) (worker+0xa34be) #2 hv::TcpClientTmplhv::WebSocketChannel::stop(bool) (worker+0xabad1) #3 main ******/enter.cpp:266 (worker+0xa0527)

Previous read of size 8 at 0x7b38000000f8 by thread T2: #0 hv::EventLoop::tid() (worker+0xa2c70) #1 hv::EventLoop::generateTimerID() (libhv.so+0x1c4f58) #2 hv::Channel::on_close(hio_s*) /home/user/work/install/libhv-1.3.1/evpp/Channel.h:221 (libhv.so+0x1c2529)

As if synchronized via sleep: #0 nanosleep ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:366 (libtsan.so.0+0x6696c) #1 void std::this_thread::sleep_for<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> > const&) /usr/include/c++/11/bits/this_thread_sleep.h:82 (worker+0xa842b) #2 main ******/enter.cpp:260 (worker+0xa0462)

Location is heap block of size 216 at 0x7b38000000e0 allocated by main thread: #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162) #1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<hv::EventLoop, std::allocatorhv::EventLoop, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/11/ext/new_allocator.h:127 (libhv.so+0x1f4ff5) #2 main ******/enter.cpp:127 (worker+0x9f3bb)

Thread T2 (tid=13955, running) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_deletestd::thread::_State >, void (*)()) (libstdc++.so.6+0xdc328) #2 main ******/enter.cpp:185 (worker+0x9ff62)

SUMMARY: ThreadSanitizer: data race (/home/user/work/project/presetup/ai-clinical-presetup/bin/worker+0xa2be0) in hv::EventLoop::stop()

================== WARNING: ThreadSanitizer: data race (pid=13949) Write of size 8 at 0x7b38000000f8 by main thread: #0 hv::EventLoop::stop() (worker+0xa2be0) #1 hv::EventLoopThread::stop(bool) (worker+0xa34be) #2 hv::TcpClientTmplhv::WebSocketChannel::stop(bool) (worker+0xabad1) #3 main ******/enter.cpp:266 (worker+0xa0527)

Previous read of size 8 at 0x7b38000000f8 by thread T2: #0 hv::EventLoop::tid() (worker+0xa2c70) #1 hv::EventLoop::generateTimerID() (libhv.so+0x1c4f58) #2 hv::Channel::on_close(hio_s*) /home/user/work/install/libhv-1.3.1/evpp/Channel.h:221 (libhv.so+0x1c2529)

As if synchronized via sleep: #0 nanosleep ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:366 (libtsan.so.0+0x6696c) #1 void std::this_thread::sleep_for<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> > const&) /usr/include/c++/11/bits/this_thread_sleep.h:82 (worker+0xa842b) #2 main ******/enter.cpp:260 (worker+0xa0462)

Location is heap block of size 216 at 0x7b38000000e0 allocated by main thread: #0 operator new(unsigned long) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:64 (libtsan.so.0+0x8f162) #1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<hv::EventLoop, std::allocatorhv::EventLoop, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/11/ext/new_allocator.h:127 (libhv.so+0x1f4ff5) #2 main ******/enter.cpp:127 (worker+0x9f3bb)

Thread T2 (tid=13961, finished) created by main thread at: #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x605b8) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_deletestd::thread::_State >, void (*)()) (libstdc++.so.6+0xdc328) #2 main ******/enter.cpp:185 (worker+0x9ff62)

SUMMARY: ThreadSanitizer: data race (/home/user/work/project/presetup/ai-clinical-presetup/bin/worker+0xa2be0) in hv::EventLoop::stop()

ThreadSanitizer: reported 1 warnings ThreadSanitizer: reported 1 warnings ThreadSanitizer: reported 1 warnings

monk1magic avatar Oct 26 '23 05:10 monk1magic