Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Lock order inversion: m_GroupLock vs m_ConnectionLock #3010

Closed
maxsharabayko opened this issue Aug 20, 2024 · 0 comments · Fixed by #3013
Closed

[BUG] Lock order inversion: m_GroupLock vs m_ConnectionLock #3010

maxsharabayko opened this issue Aug 20, 2024 · 0 comments · Fixed by #3013
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@maxsharabayko
Copy link
Collaborator

maxsharabayko commented Aug 20, 2024

WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=4255)
  Cycle in lock order graph: M628 (0x7ba8000231b0) => M686 (0x7b540001fe08) => M628

  Mutex M686 (m_GroupLock) acquired here while holding mutex M628 (m_ConnectionLock) in thread T6:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
    #1 srt::sync::Mutex::lock() .../srt-xtransmit/submodule/srt/srtcore/sync_posix.cpp:220 (srt-xtransmit+0x3e8865)
    #2 srt::sync::ScopedLock::ScopedLock(srt::sync::Mutex&) .../srt-xtransmit/submodule/srt/srtcore/sync.h:354 (srt-xtransmit+0x2b2889)    <-- m_GroupLock
    #3 srt::CUDT::makeMePeerOf(int, SRT_GROUP_TYPE, unsigned int) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:3340 (srt-xtransmit+0x302000)
    #4 srt::CUDT::interpretGroup(int const*, unsigned long, int) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:3238 (srt-xtransmit+0x30153f)
    #5 srt::CUDT::interpretSrtHandshake(srt::CHandShake const&, srt::CPacket const&, unsigned int*, unsigned long*) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:2923 (srt-xtransmit+0x2fe2fa)
    #6 srt::CUDT::acceptAndRespond(srt::sockaddr_any const&, srt::sockaddr_any const&, srt::CPacket const&, srt::CHandShake&) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:5832 (srt-xtransmit+0x311616)
    #7 srt::CUDTUnited::newConnection(int, srt::sockaddr_any const&, srt::CPacket const&, srt::CHandShake&, int&, srt::CUDT*&) .../srt-xtransmit/submodule/srt/srtcore/api.cpp:628 (srt-xtransmit+0x291779)
    #8 srt::CUDT::processConnectRequest(srt::sockaddr_any const&, srt::CPacket&) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:11249 (srt-xtransmit+0x32eb10)
    #9 srt::CRcvQueue::worker_ProcessConnectionRequest(srt::CUnit*, srt::sockaddr_any const&) .../srt-xtransmit/submodule/srt/srtcore/queue.cpp:1437 (srt-xtransmit+0x388a30)
    #10 srt::CRcvQueue::worker(void*) .../srt-xtransmit/submodule/srt/srtcore/queue.cpp:1271 (srt-xtransmit+0x387a27)

    Hint: use TSAN_OPTIONS=second_deadlock_stack=1 to get more informative warning message

  Mutex M628 (m_ConnectionLock) acquired here while holding mutex M686 (m_GroupLock) in main thread:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
    #1 srt::sync::Mutex::lock() .../srt-xtransmit/submodule/srt/srtcore/sync_posix.cpp:220 (srt-xtransmit+0x3e8865)
    #2 srt::sync::ScopedLock::ScopedLock(srt::sync::Mutex&) .../srt-xtransmit/submodule/srt/srtcore/sync.h:354 (srt-xtransmit+0x2b2889)
    #3 srt::CUDT::getOpt(SRT_SOCKOPT, void*, int&) .../srt-xtransmit/submodule/srt/srtcore/core.cpp:459 (srt-xtransmit+0x2ebaaa)   <-- m_ConnectionLock;
    #4 srt::CUDTGroup::getOpt(SRT_SOCKOPT, void*, int&) .../srt-xtransmit/submodule/srt/srtcore/group.cpp:789 (srt-xtransmit+0x3b2126)
    #5 srt::CUDT::getsockopt(int, int, SRT_SOCKOPT, void*, int*) .../srt-xtransmit/submodule/srt/srtcore/api.cpp:3877 (srt-xtransmit+0x2a8d78)
    #6 srt_getsockflag .../srt-xtransmit/submodule/srt/srtcore/srt_c_api.cpp:168 (srt-xtransmit+0x3a3e3f)
    #7 operator() .../srt-xtransmit/xtransmit/srt_socket.cpp:350 (srt-xtransmit+0x123dc2)
    #8 xtransmit::socket::srt::print_negotiated_config[abi:cxx11](int) .../srt-xtransmit/xtransmit/srt_socket.cpp:360 (srt-xtransmit+0x1240fa)
    #9 xtransmit::socket::srt_group::accept() .../srt-xtransmit/xtransmit/srt_socket_group.cpp:431 (srt-xtransmit+0x157f69)
    #10 xtransmit::create_connection(std::vector<UriParser, std::allocator<UriParser> > const&, std::shared_ptr<xtransmit::socket::isocket>&) .../srt-xtransmit/xtransmit/misc.cpp:37 (srt-xtransmit+0xe482d)
    #11 xtransmit::common_run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, xtransmit::stats_config const&, xtransmit::conn_config const&, std::atomic<bool> const&, std::function<void (std::shared_ptr<xtransmit::socket::isocket>, std::function<void (int)> const&, std::atomic<bool> const&)>&) .../srt-xtransmit/xtransmit/misc.cpp:197 (srt-xtransmit+0xe5093)
    #12 xtransmit::receive::run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, xtransmit::receive::config const&, std::atomic<bool> const&) .../srt-xtransmit/xtransmit/receive.cpp:142 (srt-xtransmit+0xf9d71)
    #13 main .../srt-xtransmit/xtransmit/xtransmit-app.cpp:231 (srt-xtransmit+0x182b2e)

SRT v1.5.3+ (eecc176).

Introduced in PR #2912.

To Reproduce

Build srt-xtransmit with Thread Sanitizer (-DCMAKE_CXX_FLAGS='-fsanitize=thread' -DWITH_COMPILER_TYPE=clang).
The error is reported on the receiver.

srt-xtransmit generate srt://172.27.16.247:4200 srt://172.27.16.247:5200 --enable-metrics --loglevel note --sendrate 5Mbps --num 2000 --reconnect --concurrent-streams 2 --maxconns 6 

srt-xtransmit receive srt://:4200 srt://:5200 --loglevel note --enable-metrics --reconnect --maxconns 6 --concurrent-streams 2

Epic #1610 – Core Synchronization Issues.

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Aug 20, 2024
@maxsharabayko maxsharabayko added this to the v1.5.4 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant