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] SIGSEGV while receiving broadcast group stream. #2133

Closed
jeandube opened this issue Sep 21, 2021 · 31 comments · Fixed by #2259
Closed

[BUG] SIGSEGV while receiving broadcast group stream. #2133

jeandube opened this issue Sep 21, 2021 · 31 comments · Fixed by #2259
Assignees
Labels
[core] Area: Changes in SRT library core Priority: High Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@jeandube
Copy link
Collaborator

Describe the bug
SIGSEGV in buffer.cpp while receiving stream over broadcast group. No network impairment added. Gdb session with log trace added.

To Reproduce
aarch64 test app caller/receiver runs on MX4D to receive MX4E listener/sender stream configured with 2 paths on 2 NICs.

{  1}srt  clnt rx Broadcast link bonding                                  STREAMING    none       evcb
{  1:1}srt        10.65.10.230:34082|10.65.10.234:9972             1.4.4  STREAMING    none       evcb
{  1:2}srt        192.168.10.230:6272|192.168.10.234:9972          1.4.4  STREAMING    none       evcb
{  2}srt  lstn tx {  1} > srt://9955                              
                    0.0.0.0:9955|                                         LISTENING    none       none
{  4}srt  lstn tx {  1} > srt://9956                              
                    0.0.0.0:9956|

mxphub70.D7log.txt

runs smoothly for ~100 min. receiving 1.5 Mbps CNN.

libsrt from branch fix-binding-any of my fork, based on 1.4.4.rc1 with fixes in api.cpp (one uncommitted fix to push).

@jeandube jeandube added the Type: Bug Indicates an unexpected problem or unintended behavior label Sep 21, 2021
@maxsharabayko
Copy link
Collaborator

Is it reproducible with v1.4.4.RC0 or v1.4.3?

@maxsharabayko
Copy link
Collaborator

maxsharabayko commented Sep 21, 2021

  • m_iStartPos = 4589,
  • m_iLastAckPos = 4598,
  • m_iMaxPos = 3 - only three unacknowledged packets, meaning that maximum position is 4601.
  • i = 4587 - completely outside the range of the loop. 🤔

Like if another thread has changed the buffer state while this thread is still inside getRcvReadyPacket(..).

for (int i = m_iStartPos, n = m_iLastAckPos; i != n; i = shiftFwd(i))
{
    if (m_pUnit[i] && m_pUnit[i]->m_iFlag == CUnit::GOOD)
    {
        HLOGC(brlog.Debug,
                log << "getRcvReadyPacket: Found next packet seq=%" << m_pUnit[i]->m_Packet.getSeqNo() << " ("
                    << nskipped << " empty cells skipped)");
        return &m_pUnit[i]->m_Packet;
    }
    IF_HEAVY_LOGGING(++nskipped);
}

@jeandube
Copy link
Collaborator Author

It takes time but it reproduces quite easily. If you know have traces I can enable in libsrt to help: here what is ON:

                     |SRT_LOGFA_BIT(SRT_LOGFA_GRP_MGMT)  //45
                     |SRT_LOGFA_BIT(SRT_LOGFA_SOCKMGMT)  //1
                     |SRT_LOGFA_BIT(SRT_LOGFA_API_CTRL)  //11
                     |SRT_LOGFA_BIT(SRT_LOGFA_HAICRYPT)  //6

@jeandube
Copy link
Collaborator Author

test restarted with v1.4.4-rc.0

@maxsharabayko
Copy link
Collaborator

In between RC.0 and RC.1 there was PR #2094 merged touching receiver buffer access, but it was intended to improve the protection. Should not be the cause of this crash, but let's see.

@maxsharabayko maxsharabayko added the [core] Area: Changes in SRT library core label Sep 22, 2021
@jeandube
Copy link
Collaborator Author

reproduced with 1.4.4-rc.0.

[Switching to LWP 10875]
0x00000000004aae70 in CRcvBuffer::getRcvReadyPacket (this=0x7fe400cc00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
1559    /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp: No such file or directory.
(gdb) bt
#0  0x00000000004aae70 in CRcvBuffer::getRcvReadyPacket (this=0x7fe400cc00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
#1  0x00000000004aab78 in CRcvBuffer::isRcvDataReady (this=0x7fe400cc00, w_tsbpdtime=..., w_curpktseq=@0x7ff68d9ba4: 127, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1479
#2  0x00000000004aaf2c in CRcvBuffer::isRcvDataReady (this=0x7fe400cc00) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1639
#3  0x0000000000510fb4 in srt::CUDTGroup::recv_WaitForReadReady (this=0x7fec000ea0, aliveMembers=..., w_broken=...)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/group.cpp:2074
#4  0x00000000005116dc in srt::CUDTGroup::recv (this=0x7fec000ea0, buf=0x7ff68db150 "G", len=1500, w_mc=...)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/group.cpp:2280
#5  0x0000000000492bfc in srt::CUDT::recvmsg2 (u=1576653796, buf=0x7ff68db150 "G", len=1500, w_m=...)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:3861
#6  0x0000000000483260 in srt_recvmsg2 (u=1576653796, buf=0x7ff68db150 "G", len=1500, mctrl=0x7ff68dafc8)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/srt_c_api.cpp:232
#7  0x00000000004578c4 in srtconn_Recv (srtc=0x5e3330, data=0x7ff68db150, datasz=1500, srctime_p=0x7ff68db0c0, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4133
#8  0x0000000000458964 in SrtConn_RecvMsg (mxpc=0x5e3330, msg=0x7fec02c420, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4221
#9  0x000000000040ae8c in srtApp_RxLoop (cx=0x5dce50) at mxphub.c:843
#10 0x000000000040c92c in srtApp_CxLoop (cx=0x5dce50, ai=0x5dddb0, openf=1) at mxphub.c:1526
#11 0x000000000040ccd0 in srtApp_CxThread (s=0x5dce50) at mxphub.c:1585
#12 0x0000007ff7b20fd8 in ?? () from /lib/libpthread.so.0
#13 0x0000007ffffff8d8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) p *this
$1 = {static DEFAULT_SIZE = 65536, m_pUnit = 0x7fe400cd00, m_iSize = 6956, m_pUnitQueue = 0x7fec008638, m_iStartPos = 6660, m_iLastAckPos = 6662, m_iMaxPos = 0, 
  m_iNotch = 0, m_BytesCountLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
          __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_iBytesCount = 3008, m_iAckedPktsCount = 2, m_iAckedBytesCount = 1692, 
  m_uAvgPayloadSz = 971, m_tsbpd = {m_iFirstRTT = 159, m_bTsbPdMode = true, m_tdTsbPdDelay = {m_duration = 250000}, m_tsTsbPdTimeBase = {m_timestamp = 3385782187613}, 
    m_bTsbPdWrapCheck = false, static TSBPD_WRAP_PERIOD = 30000000, static TSBPD_DRIFT_MAX_VALUE = 5000, static TSBPD_DRIFT_MAX_SAMPLES = 1000, m_DriftTracer = {
      m_qDrift = -1862, m_qOverdrift = 0, m_qDriftSum = 2847562400144, m_uDriftSpan = 663}, m_mtxRW = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
          __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}}, m_mavg = {
    m_tsLastSamplingTime = {m_timestamp = 3391197834598}, m_dBytesCountMAvg = 2464.8433172712644, m_dCountMAvg = 2.5986518156222043, m_dTimespanMAvg = 7.741977960538204}}
(gdb) p i
$2 = 6659
(gdb) p m_pUnit[i]
$3 = (srt::CUnit *) 0x0
(gdb)

relaunching test with 1.4.3.

@ethouris
Copy link
Collaborator

ethouris commented Sep 22, 2021

If I can see correctly, it points to this condition:

        if (m_pUnit[i] && m_pUnit[i]->m_iFlag == CUnit::GOOD)
        {
            HLOGC(brlog.Debug,
                  log << "getRcvReadyPacket: Found next packet seq=%" << m_pUnit[i]->m_Packet.getSeqNo() << " ("
                      << nskipped << " empty cells skipped)");
            return &m_pUnit[i]->m_Packet;
        }

if m_pUnit[i] == NULL then simply the first part of the condition results in false, that's all. A crash at this line might have only happened in case when the value at m_pUnit[i] has been set to NULL in the meantime in another thread. As long as I can see in the code, such a thing may only happen when the associated multiplexer is being deleted, and the sender/receiver queues are being deleted as a part of it. The problem is, it doesn't set this field to NULL. The cells of m_pUnit are set to NULL only in the beginning and never altered after being set a valid pointer. Closing a socket might do something here in between, but nothing more than just deleting the whole unit queue. Might be that i could be outside bounds - for that you can display also m_iSize.

@ethouris
Copy link
Collaborator

BTW. @jeandube any chances to run repro with thread sanitizer?

@maxsharabayko
Copy link
Collaborator

@ethouris

Might be that i could be outside bounds - for that you can display also m_iSize.

The value of i seems to be outside of the valid range. Please see my above comment here.

@ethouris
Copy link
Collaborator

Right. Same thing in Jean's post above:

m_iStartPos = 6660, m_iLastAckPos = 6662,

(gdb) p i
$2 = 6659

It looks like the m_iStartPos has been altered in the meantime. It would be nice if it can be traced where these values were taken from because it's impossible that i went back.

@ethouris
Copy link
Collaborator

m_iStartPos can be modified in several functions that are usually affined to the application receiver thread, however some of them are being used in TsbPd thread (like skipData for example).

@jeandube
Copy link
Collaborator Author

jeandube commented Sep 22, 2021

@ethouris I am currently running the test with 1.4.3 with no luck up to now. If I retrieve the recipe to build for thread sanitize I'll do it on 1.4.4-rc.0. regarding m_iSize, I printed the whole 'this' to get everything.

@gou4shi1
Copy link
Contributor

gou4shi1 commented Sep 24, 2021

Can you post the heavy log? ENABLE_HEAVY_LOGGING=1
You can also add one log as #2094 (comment)
PR #2094 just fixed a crash in same scenario.

@gou4shi1
Copy link
Contributor

If I retrieve the receipt to build for threadcheck I'll do it on 1.4.4-rc.0

1.4.4-rc.0 has been confirmed to have race condition in this function, you should try 1.4.4-rc.1

@jeandube
Copy link
Collaborator Author

@gou4shi1, thanks for your observations. I had this issue reproduced with 1.4.4-rc.1 with -fsanitizer=thread.

@jeandube
Copy link
Collaborator Author

Here the output before the crash:

WARNING: ThreadSanitizer: data race (pid=12010)
  Write of size 1 at 0x007fed871550 by thread T5:
    #0 recvmsg <null> (libtsan.so.0+0x3cccf)
    #1 srt::CChannel::recvfrom(sockaddr_any&, srt::CPacket&) const /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/channel.cpp:665 (mxphub81+0x4e35eb)

  Previous read of size 8 at 0x007fed871550 by thread T3 (mutexes: write M123, write M135, write M133):
    #0 memcpy <null> (libtsan.so.0+0x34dab)
    #1 CRcvBuffer::extractData(char*, int, int, int, bool) /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1996 (mxphub81+0x4e096f)
    #2 SrtConn_RecvMsg ../../libraries/naga/mxpmod_lib/srtc_mod.c:4221 (mxphub81+0x47d087)
    #3 srtApp_RxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:843 (mxphub81+0x40c613)
    #4 srtApp_CxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1526 (mxphub81+0x40ee17)
    #5 srtApp_CxThread /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1585 (mxphub81+0x40f46f)

  Location is heap block of size 46592 at 0x007fed86c000 allocated by thread T5:
    #0 operator new[](unsigned long) <null> (libtsan.so.0+0x72d8b)
    #1 srt::CUnitQueue::increase() /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/queue.cpp:173 (mxphub81+0x52ca53)

  Mutex M123 (0x007ff3f07b08) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x2f6f3)
    #1 srt::sync::Mutex::Mutex() /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/sync_posix.cpp:206 (mxphub81+0x4b8ce7)
    #2 srtconn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3350 (mxphub81+0x471fbb)
    #3 SrtConn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3551 (mxphub81+0x4753ef)
    #4 srtApp_CxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1388 (mxphub81+0x40e40b)
    #5 srtApp_CxThread /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1585 (mxphub81+0x40f46f)

  Mutex M135 (0x007feea052a0) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x2f6f3)
    #1 srt::sync::Mutex::Mutex() /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/sync_posix.cpp:206 (mxphub81+0x4b8ce7)
    #2 srtgroup_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3204 (mxphub81+0x4709f7)
    #3 srtconn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3350 (mxphub81+0x471fbb)
    #4 SrtConn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3551 (mxphub81+0x4753ef)
    #5 srtApp_CxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1388 (mxphub81+0x40e40b)
    #6 srtApp_CxThread /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1585 (mxphub81+0x40f46f)

  Mutex M133 (0x007feea05210) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x2f6f3)
    #1 srt::sync::Mutex::Mutex() /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/sync_posix.cpp:206 (mxphub81+0x4b8ce7)
    #2 srtgroup_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3204 (mxphub81+0x4709f7)
    #3 srtconn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3350 (mxphub81+0x471fbb)
    #4 SrtConn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3551 (mxphub81+0x4753ef)
    #5 srtApp_CxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1388 (mxphub81+0x40e40b)
    #6 srtApp_CxThread /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1585 (mxphub81+0x40f46f)

  Thread T5 'SRT:RcvQ:w1' (tid=12016, running) created by thread T3 at:
    #0 pthread_create <null> (libtsan.so.0+0x2eed7)
    #1 srt::sync::CThread::create(void* (*)(void*), void*) /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/sync_posix.cpp:448 (mxphub81+0x4b95d7)
    #2 srtgroup_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3204 (mxphub81+0x4709f7)
    #3 srtconn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3350 (mxphub81+0x471fbb)
    #4 SrtConn_Open ../../libraries/naga/mxpmod_lib/srtc_mod.c:3551 (mxphub81+0x4753ef)
    #5 srtApp_CxLoop /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1388 (mxphub81+0x40e40b)
    #6 srtApp_CxThread /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:1585 (mxphub81+0x40f46f)

  Thread T3 'App:Rx' (tid=12014, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2eed7)
    #1 mxptool_cmd /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:4775 (mxphub81+0x41d907)
    #2 main /home/jdube/sandbox/makito2_project/components/tests/mxphub/mxphub.c:4905 (mxphub81+0x41e017)

SUMMARY: ThreadSanitizer: data race (/lib/libtsan.so.0+0x3cccf) in recvmsg
==================

Thread 5 "App:Rx" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 12014]
0x00000000004df6f8 in CRcvBuffer::getRcvReadyPacket (this=0x7feec07b00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
1559    /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp: No such file or directory.
(gdb) bt
#0  0x00000000004df6f8 in CRcvBuffer::getRcvReadyPacket (this=0x7feec07b00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
#1  0x00000000004df400 in CRcvBuffer::isRcvDataReady (this=0x7feec07b00, w_tsbpdtime=..., w_curpktseq=@0x7fefebdc64: 127, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1479
#2  0x00000000004df7b4 in CRcvBuffer::isRcvDataReady (this=0x7feec07b00) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1639
#3  0x00000000004b9ff8 in srt::CUDTSocket::readReady (this=0x7feea00000) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:154
#4  0x000000000054cae0 in srt::CUDTGroup::addEPoll (this=0x7ff3f07b00, eid=1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/group.cpp:4515
#5  0x00000000004c127c in srt::CUDTUnited::epoll_add_usock (this=0x5e9ae8 <srt::CUDT::s_UDTUnited>, eid=1, u=1920432218, events=0x7fefebdfe0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:2362
#6  0x00000000004c8584 in srt::CUDT::epoll_add_usock (eid=1, u=1920432218, events=0x7fefebdfe0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:4024
#7  0x00000000004b7d6c in srt_epoll_add_usock (eid=1, u=1920432218, events=0x7fefebdfe0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/srt_c_api.cpp:271
#8  0x00000000004a1510 in mxpcUEpoll_Eoi (muep=0x7ff3503d80, sock=1920432218, wanted_events=1) at ../../libraries/naga/mxpmod_lib/mxpc_uepoll.c:728
#9  0x00000000004a181c in mxpcUEpoll_SetEoi (muep=0x7ff3503d80, sock=1920432218, wanted_events=1) at ../../libraries/naga/mxpmod_lib/mxpc_uepoll.c:760
#10 0x000000000047bbd4 in srtconn_Recv (srtc=0x7ff0302000, data=0x7fefebe5c8, datasz=1500, srctime_p=0x7fefebe458, flags=0)
    at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4161
#11 0x000000000047d088 in SrtConn_RecvMsg (mxpc=0x7ff0302000, msg=0x7ff2baaa00, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4221
#12 0x000000000040c614 in srtApp_RxLoop (cx=0x7ff3903000) at mxphub.c:843
#13 0x000000000040ee18 in srtApp_CxLoop (cx=0x7ff3903000, ai=0x7ff4300ec0, openf=1) at mxphub.c:1526
#14 0x000000000040f470 in srtApp_CxThread (s=0x7ff3903000) at mxphub.c:1585
#15 0x0000007ff7069a0c in __tsan_thread_start_func () from /lib/libtsan.so.0
#16 0x0000007ff6b8bfd8 in ?? () from /lib/libpthread.so.0
#17 0x0000007ffffff8f8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info thread
  Id   Target Id         Frame 
  1    LWP 12010 "mxphub81" 0x0000007ff6b9262c in pthread_cond_timedwait () from /lib/libpthread.so.0
  2    LWP 12011 "mxphub81" 0x0000007ff69f5294 in nanosleep () from /lib/libc.so.6
  3    LWP 12012 "SRT:GC" 0x0000007ff6b9262c in pthread_cond_timedwait () from /lib/libpthread.so.0
  4    LWP 12013 "UEpoll" 0x0000007ff6b9262c in pthread_cond_timedwait () from /lib/libpthread.so.0
* 5    LWP 12014 "App:Rx" 0x00000000004df6f8 in CRcvBuffer::getRcvReadyPacket (this=0x7feec07b00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
  6    LWP 12015 "SRT:SndQ:w1" 0x0000007ff6b92268 in pthread_cond_wait () from /lib/libpthread.so.0
  7    LWP 12016 "SRT:RcvQ:w1" 0x0000007ff6b95dcc in recvmsg () from /lib/libpthread.so.0
  8    LWP 12017 "SRT:SndQ:w2" 0x0000007ff6b92268 in pthread_cond_wait () from /lib/libpthread.so.0
  9    LWP 12018 "SRT:RcvQ:w2" 0x0000007ff6b95dcc in recvmsg () from /lib/libpthread.so.0
  10   LWP 12019 "SRT:TsbPd" 0x0000007ff6b95464 in ?? () from /lib/libpthread.so.0
  11   LWP 12020 "SRT:TsbPd" 0x0000007ff6b95494 in ?? () from /lib/libpthread.so.0
  12   LWP 12021 "SRT:SndQ:w3" 0x0000007ff6b92268 in pthread_cond_wait () from /lib/libpthread.so.0
  13   LWP 12022 "SRT:RcvQ:w3" 0x0000007ff6b95dcc in recvmsg () from /lib/libpthread.so.0
(gdb) p *this
$1 = {static DEFAULT_SIZE = 65536, m_pUnit = 0x7febe00000, m_iSize = 6956, m_pUnitQueue = 0x7fedc03d88, m_iStartPos = 4556, m_iLastAckPos = 4566, m_iMaxPos = 0, 
  m_iNotch = 0, m_BytesCountLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
          __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_iBytesCount = 10904, m_iAckedPktsCount = 10, m_iAckedBytesCount = 9588, 
  m_uAvgPayloadSz = 937, m_tsbpd = {m_iFirstRTT = 1980, m_bTsbPdMode = true, m_tdTsbPdDelay = {m_duration = 250000}, m_tsTsbPdTimeBase = {m_timestamp = 3516223027617}, 
    m_bTsbPdWrapCheck = false, static TSBPD_WRAP_PERIOD = 30000000, static TSBPD_DRIFT_MAX_VALUE = 5000, static TSBPD_DRIFT_MAX_SAMPLES = 1000, m_DriftTracer = {
      m_qDrift = -2520, m_qOverdrift = 0, m_qDriftSum = 1017905261581, m_uDriftSpan = 237}, m_mtxRW = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
          __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}}, m_mavg = {
    m_tsLastSamplingTime = {m_timestamp = 3523020279248}, m_dBytesCountMAvg = 2702.681638400732, m_dCountMAvg = 2.8254738641672232, m_dTimespanMAvg = 8.8786699093553576}}
(gdb) p i
$2 = 4553
(gdb) p m_pUnit[i]
$3 = (srt::CUnit *) 0x0

@ethouris
Copy link
Collaborator

I can see that the call to CRcvBuffer::recvMsg is protected (though by a mutex sitting in CUDT), while none of the parts starting from CRcvQueue::worker is. This, however, likely isn't the cause of the problem. The CRcvBuffer::getRcvReadyPacket should have never tried to reach outside the range between 4556 and 4566 and i=4553 is definitely outside. There's physically no possibility that if i starts from 4556 and rides towards 4566 using increasing function (until it reaches m_iSize that is 6956, so that wouldn't be the case). The only explanation is then that m_iStartPos has been shifted forwards during the roll of this loop.

This buffer has been originally developed in UDT as lock-free as it didn't need locking as there were only two threads operating on particular end - reader worker thread at the new end, application thread at the old end, outdated values of non-atomic positioners could at worst point to unused space. The problem is that in SRT there's a new thread modifying m_iStartPos field, which is TSBPD thread and CRcvBuffer::skipData call - I'd start searching there.

@jeandube
Copy link
Collaborator Author

It is clear that TSBPD thread has been implemented without a clear understanding of the UDT threading model and intrinsic protection that comes with it. Who other than me can say this :-) Now it's done. The TSBPD code should probably be run in the SRT:RcvQ thread, removing the need of many mutexes we keep adding to work around this design flaw.

@ethouris
Copy link
Collaborator

I was thinking about it, but the problem here is that its role is to trigger appropriate flags at the strictly specified time and doing it in a thread that is also doing other things in the meantime may lose some accuracy. Might be that receiver-dropping shall be simply done differently, possibly by allowing the reader to step on empty units when packets are lacking and simply skip them when retrieveing the data.

What is important, is that in this exactly place the problem is likely fixable by adding the same mutex that is used in the main thread's call.

@jeandube
Copy link
Collaborator Author

Got the crash again. Adding a dump of the socket:

[Switching to LWP 29633]
0x00000000004abf10 in CRcvBuffer::getRcvReadyPacket (this=0x7fdc00cc00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
1559    /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp: No such file or directory.
(gdb) bt
#0  0x00000000004abf10 in CRcvBuffer::getRcvReadyPacket (this=0x7fdc00cc00, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1559
#1  0x00000000004abc18 in CRcvBuffer::isRcvDataReady (this=0x7fdc00cc00, w_tsbpdtime=..., w_curpktseq=@0x7ff68da834: 127, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1479
#2  0x00000000004abfcc in CRcvBuffer::isRcvDataReady (this=0x7fdc00cc00)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1639
#3  0x0000000000485810 in srt::CUDTSocket::readReady (this=0x7fec016d60)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:154
#4  0x00000000005192f8 in srt::CUDTGroup::addEPoll (this=0x7fec000ea0, eid=1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/group.cpp:4515
#5  0x000000000048ca94 in srt::CUDTUnited::epoll_add_usock (this=0x5b6210 <srt::CUDT::s_UDTUnited>, eid=1, u=1215960114, events=0x7ff68dabb0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:2362
#6  0x0000000000493d9c in srt::CUDT::epoll_add_usock (eid=1, u=1215960114, events=0x7ff68dabb0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:4024
#7  0x0000000000483584 in srt_epoll_add_usock (eid=1, u=1215960114, events=0x7ff68dabb0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/srt_c_api.cpp:271
#8  0x0000000000472bfc in mxpcUEpoll_Eoi (muep=0x7fec001370, sock=1215960114, wanted_events=1)
    at ../../libraries/naga/mxpmod_lib/mxpc_uepoll.c:728
#9  0x0000000000472dbc in mxpcUEpoll_SetEoi (muep=0x7fec001370, sock=1215960114, wanted_events=1)
    at ../../libraries/naga/mxpmod_lib/mxpc_uepoll.c:760
#10 0x0000000000457a48 in srtconn_Recv (srtc=0x5e3f00, data=0x7ff68db150, datasz=1500, srctime_p=0x7ff68db0c0, flags=0)
    at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4161
#11 0x0000000000458964 in SrtConn_RecvMsg (mxpc=0x5e3f00, msg=0x7fec02c410, flags=0) at ../../libraries/naga/mxpmod_lib/srtc_mod.c:4221
#12 0x000000000040ae8c in srtApp_RxLoop (cx=0x5dee50) at mxphub.c:843
#13 0x000000000040c92c in srtApp_CxLoop (cx=0x5dee50, ai=0x5dfdb0, openf=1) at mxphub.c:1526
#14 0x000000000040ccd0 in srtApp_CxThread (s=0x5dee50) at mxphub.c:1585
#15 0x0000007ff7b20fd8 in ?? () from /lib/libpthread.so.0
#16 0x0000007ffffff908 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) p *this
$1 = {static DEFAULT_SIZE = 65536, m_pUnit = 0x7fdc00cd00, m_iSize = 6956, m_pUnitQueue = 0x7fec01dbb8, m_iStartPos = 5061, 
  m_iLastAckPos = 5068, m_iMaxPos = 2, m_iNotch = 0, m_BytesCountLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
        __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
  m_iBytesCount = 156604, m_iAckedPktsCount = 7, m_iAckedBytesCount = 7708, m_uAvgPayloadSz = 1080, m_tsbpd = {m_iFirstRTT = 127, 
    m_bTsbPdMode = true, m_tdTsbPdDelay = {m_duration = 250000}, m_tsTsbPdTimeBase = {m_timestamp = 192027857601}, m_bTsbPdWrapCheck = false, 
    static TSBPD_WRAP_PERIOD = 30000000, static TSBPD_DRIFT_MAX_VALUE = 5000, static TSBPD_DRIFT_MAX_SAMPLES = 1000, m_DriftTracer = {
      m_qDrift = 4294960141, m_qOverdrift = 0, m_qDriftSum = 8065941796821, m_uDriftSpan = 939}, m_mtxRW = {m_mutex = {__data = {__lock = 0, 
          __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}}, m_mavg = {m_tsLastSamplingTime = {m_timestamp = 202242192738}, 
    m_dBytesCountMAvg = 2857.3780624978976, m_dCountMAvg = 2.5070169132969071, m_dTimespanMAvg = 12.972545759020349}}
(gdb) up
#1  0x00000000004abc18 in CRcvBuffer::isRcvDataReady (this=0x7fdc00cc00, w_tsbpdtime=..., w_curpktseq=@0x7ff68da834: 127, seqdistance=-1)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1479
1479    in /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp
(gdb) up
#2  0x00000000004abfcc in CRcvBuffer::isRcvDataReady (this=0x7fdc00cc00)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1639
1639    in /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp
(gdb) up
#3  0x0000000000485810 in srt::CUDTSocket::readReady (this=0x7fec016d60)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:154
154     /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp: No such file or directory.
(gdb) p *this
$2 = {m_Status = {value_ = SRTS_CONNECTED}, m_tsClosureTimeStamp = {m_timestamp = 0}, m_SelfAddr = {{sin = {sin_family = 2, sin_port = 36246, 
        sin_addr = {s_addr = 3859431690}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 2, sin6_port = 36246, 
        sin6_flowinfo = 3859431690, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, 
            __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sa = {sa_family = 2, 
        sa_data = "\226\215\nA\n\346\000\000\000\000\000\000\000"}}, len = 16}, m_PeerAddr = {{sin = {sin_family = 2, sin_port = 62758, 
        sin_addr = {s_addr = 4043981066}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 2, sin6_port = 62758, 
        sin6_flowinfo = 4043981066, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 12 times>, "\177\000\000", __u6_addr16 = {0, 0, 0, 
              0, 0, 0, 127, 0}, __u6_addr32 = {0, 0, 0, 127}}}, sin6_scope_id = 10}, sa = {sa_family = 2, 
        sa_data = "&\365\nA\n\361\000\000\000\000\000\000\000"}}, len = 16}, m_SocketID = 142218288, m_ListenSocket = 0, m_PeerID = 0, 
  m_GroupMemberData = 0x7fec01c620, m_GroupOf = 0x7fec000ea0, m_iISN = 0, m_UDT = {static INVALID_SOCK = -1, static ERROR = -1, 
    static HS_VERSION_UDT4 = 4, static HS_VERSION_SRT1 = 5, static COMM_RESPONSE_MAX_EXP = 16, static SRT_TLPKTDROP_MINTHRESHOLD_MS = 1000, 
    static COMM_KEEPALIVE_PERIOD_US = 1000000, static COMM_SYN_INTERVAL_US = 10000, static COMM_CLOSE_BROKEN_LISTENER_TIMEOUT_MS = 3000, 
    static MAX_WEIGHT = 32767, static ACK_WND_SIZE = 1024, static INITIAL_RTT = 100000, static INITIAL_RTTVAR = 50000, 
    m_config = {<CSrtMuxerConfig> = {static DEF_UDP_BUFFER_SIZE = 65536, iIpTTL = 24, iIpToS = 184, iIpV6Only = 0, bReuseAddr = true, 
        sBindToDevice = {static npos = 18446744073709551615, 
          _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
            _M_p = 0x7fec016df8 ""}, _M_string_length = 0, {_M_local_buf = '\000' <repeats 15 times>, _M_allocated_capacity = 0}}, 
        iUDPSndBufSize = 1024000, iUDPRcvBufSize = 1024000}, static DEF_MSS = 1500, static DEF_FLIGHT_SIZE = 25600, 
      static DEF_BUFFER_SIZE = 8192, static DEF_LINGER_S = 180, static DEF_CONNTIMEO_S = 3, static COMM_RESPONSE_TIMEOUT_MS = 5000, 
      static COMM_DEF_STABILITY_TIMEOUT_US = 80000, static DEF_MIN_FLIGHT_PKT = 32, static MAX_SID_LENGTH = 512, 
      static MAX_PFILTER_LENGTH = 64, static MAX_CONG_LENGTH = 16, iMSS = 1496, zExpPayloadSize = 1316, bSynSending = false, 
      bSynRecving = false, iFlightFlagSize = 25600, iSndBufSize = 6956, iRcvBufSize = 6956, Linger = {l_onoff = 0, l_linger = 0}, 
      bRendezvous = false, tdConnTimeOut = {m_duration = 8000000}, bDriftTracer = true, iSndTimeOut = -1, iRcvTimeOut = -1, llMaxBW = -1, 
      CryptoSecret = {typ = 0, len = 0, str = '\000' <repeats 79 times>}, iSndCryptoKeyLen = 0, bDataSender = false, bMessageAPI = true, 
      bTSBPD = true, iRcvLatency = 20, iPeerLatency = 20, bTLPktDrop = true, iSndDropDelay = 0, bEnforcedEnc = false, iGroupConnect = 1, 
      iPeerIdleTimeout = 15000, uStabilityTimeout = 80000, iRetransmitAlgo = 0, llInputBW = 0, llMinInputBW = 0, iOverheadBW = 25, 
      bRcvNakReport = true, iMaxReorderTolerance = 0, uKmRefreshRatePkt = 0, uKmPreAnnouncePkt = 0, uSrtVersion = 66564, 
      uMinimumPeerSrtVersion = 65536, sCongestion = {stor = "live", '\000' <repeats 12 times>, len = 4}, sPacketFilterConfig = {
        stor = '\000' <repeats 64 times>, len = 0}, sStreamName = {stor = '\000' <repeats 512 times>, len = 0}}, m_cbPacketArrival = {
      opaque = 0x0, fn = 0x0}, static s_UDTUnited = {static MAX_SOCKET_VAL = 1073741823, m_Sockets = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTSocket*> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTSocket*> > >> = {<No data fields>}, <No data fields>}, 
            _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x7fec01c850, _M_left = 0x7fec0073c0, _M_right = 0x7fec001620}, _M_node_count = 4}}}, 
      m_Groups = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTGroup*> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTGroup*> > >> = {<No data fields>}, <No data fields>}, 
            _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x7fec000bf0, _M_left = 0x7fec000bf0, _M_right = 0x7fec000bf0}, _M_node_count = 1}}}, 
      m_GlobControlLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {
              __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_IDLock = {m_mutex = {__data = {__lock = 0, 
            __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
          __size = '\000' <repeats 47 times>, __align = 0}}, m_SocketIDGenerator = 142218284, m_SocketIDGenerator_init = 142218291, 
      m_PeerRec = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<long const, std::set<int, std::less<int>, std::allocator<int> > > > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<long const, std::set<int, std::less<int>, std::allocator<int> > > > >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<long, long, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x5b62e0 <srt::CUDT::s_UDTUnited+208>, 
              _M_right = 0x5b62e0 <srt::CUDT::s_UDTUnited+208>}, _M_node_count = 0}}}, m_mMultiplexer = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, srt::CMultiplexer> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, srt::CMultiplexer> > >> = {<No data fields>}, <No data fields>}, 
            _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x7fec02c1f0, _M_left = 0x7fec049360, _M_right = 0x7fec016c70}, _M_node_count = 3}}}, 
---Type <return> to continue, or q <return> to quit---
      m_MultiplexerLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {
              __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_pCache = 0x5cc3d0, m_bClosing = {
        value_ = false}, m_GCStopLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 1, __kind = 0, __spins = 0, 
            __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 12 times>, "\001", '\000' <repeats 34 times>, __align = 0}}, 
      m_GCStopCond = {m_cv = {__data = {__lock = 0, __futex = 37605, __total_seq = 18803, __wakeup_seq = 18802, __woken_seq = 18802, 
            __mutex = 0x5b6378 <srt::CUDT::s_UDTUnited+360>, __nwaiters = 3, __broadcast_seq = 0}, 
          __size = "\000\000\000\000\345\222\000\000sI\000\000\000\000\000\000rI\000\000\000\000\000\000rI\000\000\000\000\000\000xc[\000\000\000\000\000\003\000\000\000\000\000\000", __align = 161512245166080}}, m_InitLock = {m_mutex = {__data = {__lock = 0, __count = 0, 
            __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
          __align = 0}}, m_iInstanceCount = 5, m_bGCStatus = true, m_GCThread = {m_thread = 549614109152}, m_ClosedSockets = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTSocket*> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTSocket*> > >> = {<No data fields>}, <No data fields>}, 
            _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x5b6420 <srt::CUDT::s_UDTUnited+528>, 
              _M_right = 0x5b6420 <srt::CUDT::s_UDTUnited+528>}, _M_node_count = 0}}}, m_ClosedGroups = {_M_t = {
          _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTGroup*> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, srt::CUDTGroup*> > >> = {<No data fields>}, <No data fields>}, 
            _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
              _M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x5b6450 <srt::CUDT::s_UDTUnited+576>, 
              _M_right = 0x5b6450 <srt::CUDT::s_UDTUnited+576>}, _M_node_count = 0}}}, m_EPoll = {m_iIDSeed = 3, m_SeedLock = {m_mutex = {
            __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
            __size = '\000' <repeats 47 times>, __align = 0}}, m_mPolls = {_M_t = {
            _M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, CEPollDesc> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, CEPollDesc> > >> = {<No data fields>}, <No data fields>}, 
              _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
                _M_color = std::_S_red, _M_parent = 0x7fec000c30, _M_left = 0x5debb0, _M_right = 0x7fec000cf0}, _M_node_count = 3}}}, 
        m_EPollLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {
                __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}}}, m_parent = 0x7fec016d60, 
    m_SocketID = 142218288, m_PeerID = 184213321, m_tsSndHsLastTime = {m_timestamp = 0}, m_iSndHsRetryCnt = 0, 
    m_HSGroupType = SRT_GTYPE_UNDEFINED, m_iMaxSRTPayloadSize = 1452, m_iTsbPdDelay_ms = 250, m_iPeerTsbPdDelay_ms = 250, 
    m_bTLPktDrop = true, m_pCryptoControl = {
      _M_t = {<std::_Tuple_impl<0ul, CCryptoControl*, std::default_delete<CCryptoControl> >> = {<std::_Tuple_impl<1ul, std::default_delete<CCryptoControl> >> = {<std::_Head_base<1ul, std::default_delete<CCryptoControl>, true>> = {<std::default_delete<CCryptoControl>> = {<No data fields>}, <No data fields>}, <No data fields>}, <std::_Head_base<0ul, CCryptoControl*, false>> = {
            _M_head_impl = 0x7fdc0009a0}, <No data fields>}, <No data fields>}}, m_pCache = 0x5cc3d0, m_Slots = {
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x7fdc01a7c0, _M_finish = 0x7fdc01a7c8, _M_end_of_storage = 0x7fdc01a7c8}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x7fdc01a770, _M_finish = 0x7fdc01a778, _M_end_of_storage = 0x7fdc01a778}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x7fdc000b70, _M_finish = 0x7fdc000b78, _M_end_of_storage = 0x7fdc000b78}}, <No data fields>}, 
---Type <return> to continue, or q <return> to quit---
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, 
      {<std::_Vector_base<EventSlot, std::allocator<EventSlot> >> = {
          _M_impl = {<std::allocator<EventSlot>> = {<__gnu_cxx::new_allocator<EventSlot>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, m_CongCtl = {static N_CONTROLLERS = 2, 
      static congctls = {{first = 0x552f68 "live", second = 0x505774 <srt::Creator<srt::LiveCC>::Create(srt::CUDT*)>}, {
          first = 0x552f70 "file", second = 0x5057c8 <srt::Creator<srt::FileCC>::Create(srt::CUDT*)>}}, congctl = 0x7fdc01a6c0, 
      selector = 0}, m_PacketFilter = {static builtin_filters = <optimized out>, static filters = <optimized out>, m_filter = 0x0, 
      m_parent = 0x0, m_sndctlpkt = {hdr = {0, 0, 0, 0}, buffer = '\000' <repeats 96 times>, "\361\234", '\000' <repeats 1357 times>, 
        length = 0}, m_unitq = 0x0, m_provided = {<std::_Vector_base<srt::SrtPacket, std::allocator<srt::SrtPacket> >> = {
          _M_impl = {<std::allocator<srt::SrtPacket>> = {<__gnu_cxx::new_allocator<srt::SrtPacket>> = {<No data fields>}, <No data fields>}, 
            _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, m_PktFilterRexmitLevel = srt::SRT_ARQ_ALWAYS, 
    m_sPeerPktFilterConfigString = {static npos = 18446744073709551615, 
      _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
        _M_p = 0x7fec0178a8 ""}, _M_string_length = 0, {_M_local_buf = '\000' <repeats 15 times>, _M_allocated_capacity = 0}}, 
    m_bListening = {value_ = false}, m_bConnecting = {value_ = false}, m_bConnected = {value_ = true}, m_bClosing = {value_ = false}, 
    m_bShutdown = {value_ = false}, m_bBroken = {value_ = false}, m_bBreakAsUnstable = {value_ = false}, m_bPeerHealth = {value_ = true}, 
    m_RejectReason = {value_ = 0}, m_bOpened = true, m_iBrokenCounter = {value_ = 0}, m_iEXPCount = 1, m_iBandwidth = {value_ = 1}, 
    m_iSRTT = {value_ = 119}, m_iRTTVar = {value_ = 7}, m_bIsFirstRTTReceived = {value_ = true}, m_iDeliveryRate = {value_ = 16}, 
    m_iByteDeliveryRate = {value_ = 23296}, m_ConnReq = {static m_iContentSize = 48, static HS_EXT_HSREQ = 1, static HS_EXT_KMREQ = 2, 
      static HS_EXT_CONFIG = 4, m_iVersion = 5, m_iType = 5, m_iISN = 397391221, m_iMSS = 1500, m_iFlightFlagSize = 6956, 
      m_iReqType = URQ_CONCLUSION, m_iID = 142218288, m_iCookie = -483752626, m_piPeerIP = {4043981066, 0, 0, 0}, m_extension = true}, 
    m_ConnRes = {static m_iContentSize = 48, static HS_EXT_HSREQ = 1, static HS_EXT_KMREQ = 2, static HS_EXT_CONFIG = 4, m_iVersion = 5, 
      m_iType = 5, m_iISN = 397391221, m_iMSS = 1496, m_iFlightFlagSize = 6975, m_iReqType = URQ_CONCLUSION, m_iID = 184213321, 
      m_iCookie = -483752626, m_piPeerIP = {3859431690, 0, 0, 0}, m_extension = false}, m_RdvState = CHandShake::RDV_INVALID, 
    m_SrtHsSide = HSD_INITIATOR, m_pSndBuffer = 0x7fdc000b90, m_pSndLossList = 0x7fdc01a670, 
    m_SndTimeWindow = {<CPktTimeWindowTools> = {<No data fields>}, m_aPktWindow = {1000000 <repeats 16 times>}, m_aBytesWindow = {
        1456 <repeats 16 times>}, m_iPktWindowPtr = 0, m_lockPktWindow = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
            __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
      m_aProbeWindow = {1000 <repeats 16 times>}, m_iProbeWindowPtr = 0, m_lockProbeWindow = {m_mutex = {__data = {__lock = 0, __count = 0, 
            __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
          __align = 0}}, m_iLastSentTime = 0, m_iMinPktSndInt = 1000000, m_tsLastArrTime = {m_timestamp = 183437909671}, m_tsCurrArrTime = {
        m_timestamp = 0}, m_tsProbeTime = {m_timestamp = 0}, m_Probe1Sequence = -1}, m_tdSendInterval = {dur = {value_ = 10}}, 
    m_tdSendTimeDiff = {dur = {value_ = 0}}, m_iFlowWindowSize = {value_ = 6975}, m_dCongestionWindow = 6975, m_tsNextACKTime = {dur = {
        value_ = 202242236052}}, m_tsNextNAKTime = {dur = {value_ = 202242253533}}, m_tdACKInterval = {m_duration = 10000}, 
    m_tdNAKInterval = {m_duration = 20000}, m_tsLastRspTime = {dur = {value_ = 202242233524}}, m_tsLastRspAckTime = {
      m_timestamp = 183437920310}, m_tsLastSndTime = {dur = {value_ = 202242226128}}, m_tsLastWarningTime = {m_timestamp = 0}, 
    m_tsLastReqTime = {dur = {value_ = 0}}, m_tsRcvPeerStartTime = {m_timestamp = 183437918009}, m_tsLingerExpiration = {m_timestamp = 0}, 
    m_tsLastAckTime = {m_timestamp = 202242226069}, m_tdMinNakInterval = {m_duration = 20000}, m_tdMinExpInterval = {m_duration = 300000}, 
    m_iPktCount = 2, m_iLightACKCount = 1, m_tsNextSendTime = {m_timestamp = 0}, m_iSndLastFullAck = {value_ = 397391221}, m_iSndLastAck = {
      value_ = 397391221}, m_iSndLastDataAck = {value_ = 397391221}, m_iSndCurrSeqNo = {value_ = 397391220}, m_iSndNextSeqNo = {
      value_ = 397391221}, m_iSndLastAck2 = 397391221, m_SndLastAck2Time = {m_timestamp = 183437914883}, m_iISN = 397391221, 
    m_bPeerTsbPd = true, m_bPeerTLPktDrop = true, m_bPeerNakReport = true, m_bPeerRexmitFlag = true, m_iReXmitCount = 1, 
    m_pRcvBuffer = 0x7fdc00cc00, m_pRcvLossList = 0x7fdc000b50, 
    m_FreshLoss = {<std::_Deque_base<CRcvFreshLoss, std::allocator<CRcvFreshLoss> >> = {
        _M_impl = {<std::allocator<CRcvFreshLoss>> = {<__gnu_cxx::new_allocator<CRcvFreshLoss>> = {<No data fields>}, <No data fields>}, 
          _M_map = 0x7fec01c3c0, _M_map_size = 8, _M_start = {_M_cur = 0x7fec01c410, _M_first = 0x7fec01c410, _M_last = 0x7fec01c608, 
            _M_node = 0x7fec01c3d8}, _M_finish = {_M_cur = 0x7fec01c410, _M_first = 0x7fec01c410, _M_last = 0x7fec01c608, 
            _M_node = 0x7fec01c3d8}}}, <No data fields>}, m_iReorderTolerance = 0, m_iConsecEarlyDelivery = 0, m_iConsecOrderedDelivery = 40, 
    m_ACKWindow = {m_aSeq = {{iACKSeqNo = -1, iACK = 400776905, tsTimeStamp = {m_timestamp = 202242226127}}, {iACKSeqNo = 1231556, 
          iACK = 400762234, tsTimeStamp = {m_timestamp = 202160206256}}, {iACKSeqNo = 1211377, iACK = 400706748, tsTimeStamp = {
            m_timestamp = 201852624107}}, {iACKSeqNo = 1211378, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852640107}}, {
---Type <return> to continue, or q <return> to quit---
          iACKSeqNo = 1211379, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852656109}}, {iACKSeqNo = 1211380, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852672097}}, {iACKSeqNo = 1211381, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852688099}}, {
          iACKSeqNo = 1211382, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852704100}}, {iACKSeqNo = 1211383, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852720093}}, {iACKSeqNo = 1211384, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852736074}}, {
          iACKSeqNo = 1211385, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852752223}}, {iACKSeqNo = 1211386, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852768079}}, {iACKSeqNo = 1211387, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852784075}}, {
          iACKSeqNo = 1211388, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852800077}}, {iACKSeqNo = 1211389, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852816084}}, {iACKSeqNo = 1211390, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852832065}}, {
          iACKSeqNo = 1211391, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852848074}}, {iACKSeqNo = 1211392, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852864070}}, {iACKSeqNo = 1211393, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852880067}}, {
          iACKSeqNo = 1211394, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852896067}}, {iACKSeqNo = 1211395, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852912066}}, {iACKSeqNo = 1211396, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852928062}}, {
          iACKSeqNo = 1211397, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852944071}}, {iACKSeqNo = 1211398, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201852960067}}, {iACKSeqNo = 1211399, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852976063}}, {
          iACKSeqNo = 1211400, iACK = 400706748, tsTimeStamp = {m_timestamp = 201852992064}}, {iACKSeqNo = 1211401, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853008064}}, {iACKSeqNo = 1211402, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853024064}}, {
          iACKSeqNo = 1211403, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853040065}}, {iACKSeqNo = 1211404, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853056065}}, {iACKSeqNo = 1211405, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853072073}}, {
          iACKSeqNo = 1211406, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853088072}}, {iACKSeqNo = 1211407, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853104072}}, {iACKSeqNo = 1211408, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853120065}}, {
          iACKSeqNo = 1211409, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853136101}}, {iACKSeqNo = 1211410, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853152077}}, {iACKSeqNo = 1211411, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853168062}}, {
          iACKSeqNo = 1211412, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853184063}}, {iACKSeqNo = 1211413, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853200062}}, {iACKSeqNo = 1211414, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853216063}}, {
          iACKSeqNo = 1211415, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853232073}}, {iACKSeqNo = 1211416, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853248069}}, {iACKSeqNo = 1211417, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853264064}}, {
          iACKSeqNo = 1211418, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853280074}}, {iACKSeqNo = 1211419, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853296066}}, {iACKSeqNo = 1211420, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853312064}}, {
          iACKSeqNo = 1211421, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853328064}}, {iACKSeqNo = 1211422, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853344065}}, {iACKSeqNo = 1211423, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853360071}}, {
          iACKSeqNo = 1211424, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853376077}}, {iACKSeqNo = 1211425, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853392076}}, {iACKSeqNo = 1211426, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853408066}}, {
          iACKSeqNo = 1211427, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853424085}}, {iACKSeqNo = 1211428, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853444081}}, {iACKSeqNo = 1211429, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853460079}}, {
          iACKSeqNo = 1211430, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853472084}}, {iACKSeqNo = 1211431, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853484074}}, {iACKSeqNo = 1211432, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853504082}}, {
          iACKSeqNo = 1211433, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853516078}}, {iACKSeqNo = 1211434, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853532109}}, {iACKSeqNo = 1211435, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853552076}}, {
          iACKSeqNo = 1211436, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853564078}}, {iACKSeqNo = 1211437, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853580075}}, {iACKSeqNo = 1211438, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853596076}}, {
          iACKSeqNo = 1211439, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853608086}}, {iACKSeqNo = 1211440, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853620074}}, {iACKSeqNo = 1211441, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853640090}}, {
          iACKSeqNo = 1211442, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853652078}}, {iACKSeqNo = 1211443, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853672080}}, {iACKSeqNo = 1211444, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853688066}}, {
          iACKSeqNo = 1211445, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853704177}}, {iACKSeqNo = 1211446, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853720066}}, {iACKSeqNo = 1211447, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853736175}}, {
          iACKSeqNo = 1211448, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853752069}}, {iACKSeqNo = 1211449, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853768179}}, {iACKSeqNo = 1211450, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853784067}}, {
          iACKSeqNo = 1211451, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853800069}}, {iACKSeqNo = 1211452, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853816068}}, {iACKSeqNo = 1211453, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853832085}}, {
          iACKSeqNo = 1211454, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853852069}}, {iACKSeqNo = 1211455, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853864064}}, {iACKSeqNo = 1211456, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853876060}}, {
          iACKSeqNo = 1211457, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853888062}}, {iACKSeqNo = 1211458, iACK = 400706748, 
---Type <return> to continue, or q <return> to quit---
          tsTimeStamp = {m_timestamp = 201853908063}}, {iACKSeqNo = 1211459, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853920059}}, {
          iACKSeqNo = 1211460, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853932065}}, {iACKSeqNo = 1211461, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853944070}}, {iACKSeqNo = 1211462, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853956060}}, {
          iACKSeqNo = 1211463, iACK = 400706748, tsTimeStamp = {m_timestamp = 201853968059}}, {iACKSeqNo = 1211464, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201853988063}}, {iACKSeqNo = 1211465, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854000062}}, {
          iACKSeqNo = 1211466, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854020058}}, {iACKSeqNo = 1211467, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854040063}}, {iACKSeqNo = 1211468, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854052068}}, {
          iACKSeqNo = 1211469, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854064062}}, {iACKSeqNo = 1211470, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854076061}}, {iACKSeqNo = 1211471, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854088063}}, {
          iACKSeqNo = 1211472, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854100061}}, {iACKSeqNo = 1211473, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854112058}}, {iACKSeqNo = 1211474, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854132062}}, {
          iACKSeqNo = 1211475, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854148065}}, {iACKSeqNo = 1211476, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854168062}}, {iACKSeqNo = 1211477, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854180058}}, {
          iACKSeqNo = 1211478, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854192063}}, {iACKSeqNo = 1211479, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854204059}}, {iACKSeqNo = 1211480, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854220059}}, {
          iACKSeqNo = 1211481, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854232064}}, {iACKSeqNo = 1211482, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854252060}}, {iACKSeqNo = 1211483, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854272090}}, {
          iACKSeqNo = 1211484, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854284102}}, {iACKSeqNo = 1211485, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854300064}}, {iACKSeqNo = 1211486, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854316067}}, {
          iACKSeqNo = 1211487, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854332066}}, {iACKSeqNo = 1211488, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854348081}}, {iACKSeqNo = 1211489, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854368088}}, {
          iACKSeqNo = 1211490, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854380077}}, {iACKSeqNo = 1211491, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854392091}}, {iACKSeqNo = 1211492, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854408068}}, {
          iACKSeqNo = 1211493, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854424064}}, {iACKSeqNo = 1211494, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854440068}}, {iACKSeqNo = 1211495, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854460078}}, {
          iACKSeqNo = 1211496, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854472080}}, {iACKSeqNo = 1211497, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854488066}}, {iACKSeqNo = 1211498, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854504065}}, {
          iACKSeqNo = 1211499, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854524061}}, {iACKSeqNo = 1211500, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854540061}}, {iACKSeqNo = 1211501, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854556060}}, {
          iACKSeqNo = 1211502, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854572060}}, {iACKSeqNo = 1211503, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854584063}}, {iACKSeqNo = 1211504, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854604075}}, {
          iACKSeqNo = 1211505, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854624062}}, {iACKSeqNo = 1211506, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854636064}}, {iACKSeqNo = 1211507, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854656059}}, {
          iACKSeqNo = 1211508, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854676063}}, {iACKSeqNo = 1211509, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854692066}}, {iACKSeqNo = 1211510, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854704058}}, {
          iACKSeqNo = 1211511, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854716062}}, {iACKSeqNo = 1211512, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854736059}}, {iACKSeqNo = 1211513, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854748061}}, {
          iACKSeqNo = 1211514, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854764062}}, {iACKSeqNo = 1211515, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854776061}}, {iACKSeqNo = 1211516, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854792072}}, {
          iACKSeqNo = 1211517, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854808058}}, {iACKSeqNo = 1211518, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854828063}}, {iACKSeqNo = 1211519, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854848107}}, {
          iACKSeqNo = 1211520, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854860125}}, {iACKSeqNo = 1211521, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854876101}}, {iACKSeqNo = 1211522, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854888103}}, {
          iACKSeqNo = 1211523, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854900071}}, {iACKSeqNo = 1211524, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854912063}}, {iACKSeqNo = 1211525, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854928059}}, {
          iACKSeqNo = 1211526, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854940061}}, {iACKSeqNo = 1211527, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201854960060}}, {iACKSeqNo = 1211528, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854976076}}, {
          iACKSeqNo = 1211529, iACK = 400706748, tsTimeStamp = {m_timestamp = 201854988072}}, {iACKSeqNo = 1211530, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855000067}}, {iACKSeqNo = 1211531, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855020062}}, {
          iACKSeqNo = 1211532, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855032060}}, {iACKSeqNo = 1211533, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855044063}}, {iACKSeqNo = 1211534, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855056077}}, {
          iACKSeqNo = 1211535, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855072066}}, {iACKSeqNo = 1211536, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855088065}}, {iACKSeqNo = 1211537, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855104064}}, {
---Type <return> to continue, or q <return> to quit---
          iACKSeqNo = 1211538, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855120065}}, {iACKSeqNo = 1211539, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855136107}}, {iACKSeqNo = 1211540, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855152094}}, {
          iACKSeqNo = 1211541, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855172081}}, {iACKSeqNo = 1211542, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855184095}}, {iACKSeqNo = 1211543, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855200080}}, {
          iACKSeqNo = 1211544, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855212088}}, {iACKSeqNo = 1211545, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855224085}}, {iACKSeqNo = 1211546, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855240081}}, {
          iACKSeqNo = 1211547, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855256083}}, {iACKSeqNo = 1211548, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855272063}}, {iACKSeqNo = 1211549, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855288063}}, {
          iACKSeqNo = 1211550, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855304063}}, {iACKSeqNo = 1211551, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855320085}}, {iACKSeqNo = 1211552, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855336081}}, {
          iACKSeqNo = 1211553, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855352081}}, {iACKSeqNo = 1211554, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855368086}}, {iACKSeqNo = 1211555, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855384084}}, {
          iACKSeqNo = 1211556, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855400069}}, {iACKSeqNo = 1211557, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855416085}}, {iACKSeqNo = 1211558, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855432078}}, {
          iACKSeqNo = 1211559, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855448081}}, {iACKSeqNo = 1211560, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855464081}}, {iACKSeqNo = 1211561, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855480080}}, {
          iACKSeqNo = 1211562, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855496063}}, {iACKSeqNo = 1211563, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855512068}}, {iACKSeqNo = 1211564, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855528071}}, {
          iACKSeqNo = 1211565, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855544068}}, {iACKSeqNo = 1211566, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855560067}}, {iACKSeqNo = 1211567, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855576068}}, {
          iACKSeqNo = 1211568, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855592170}}, {iACKSeqNo = 1211569, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855608082}}, {iACKSeqNo = 1211570, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855624068}}, {
          iACKSeqNo = 1211571, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855640065}}, {iACKSeqNo = 1211572, iACK = 400706748, 
          tsTimeStamp = {m_timestamp = 201855656066}}, {iACKSeqNo = 1211573, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855672172}}, {
          iACKSeqNo = 1211574, iACK = 400706748, tsTimeStamp = {m_timestamp = 201855688069}}...}, m_iHead = 0, m_iTail = 0}, 
    m_RcvTimeWindow = {<CPktTimeWindowTools> = {<No data fields>}, m_aPktWindow = {3710, 5405, 3800, 23, 12899, 3790, 3719, 9152, 3770, 3721, 
        9240, 3777, 3708, 12943, 3794, 3733}, m_aBytesWindow = {564, 1316, 1316, 376, 1316, 1316, 564, 1316, 1316, 564, 1316, 1316, 752, 
        1316, 1316, 1316}, m_iPktWindowPtr = 13, m_lockPktWindow = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, 
            __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
      m_aProbeWindow = {38, 5998, 14180, 10149, 125, 10076, 14245, 611, 656, 10045, 10083, 121, 26, 25, 33, 27, 44, 59, 9668, 69, 64, 14212, 
        85, 9971, 38, 10188, 81, 112, 192, 89, 14259, 48, 25, 28, 73, 1698, 28, 37, 189, 486, 170, 5957, 128, 224, 44, 356, 232, 89, 212, 
        10205, 171, 311, 131, 92, 47, 75, 27, 25, 10088, 44, 499, 48, 471, 27}, m_iProbeWindowPtr = 30, m_lockProbeWindow = {m_mutex = {
          __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
          __size = '\000' <repeats 47 times>, __align = 0}}, m_iLastSentTime = 0, m_iMinPktSndInt = 1000000, m_tsLastArrTime = {
        m_timestamp = 202242233525}, m_tsCurrArrTime = {m_timestamp = 202242233525}, m_tsProbeTime = {m_timestamp = 202242179727}, 
      m_Probe1Sequence = -1}, m_iRcvLastAck = 400776905, m_iDebugPrevLastAck = 397391221, m_iRcvLastSkipAck = 400776905, 
    m_iRcvLastAckAck = 400776905, m_iAckSeqNo = 1236900, m_iRcvCurrSeqNo = {value_ = 400776906}, m_iRcvCurrPhySeqNo = 400776906, 
    m_iPeerISN = 397391221, m_uPeerSrtVersion = 66564, m_uPeerSrtFlags = 191, m_bTsbPd = true, m_bGroupTsbPd = false, m_RcvTsbPdThread = {
      m_thread = 549075919328}, m_RcvTsbPdCond = {m_cv = {__data = {__lock = 0, __futex = 4891018, __total_seq = 2445509, 
          __wakeup_seq = 2445509, __woken_seq = 2445509, __mutex = 0x7fec01c000, __nwaiters = 1, __broadcast_seq = 0}, 
        __size = "\000\000\000\000\212\241J\000\305P%\000\000\000\000\000\305P%\000\000\000\000\000\305P%\000\000\000\000\000\000\300\001\354\177\000\000\000\001\000\000\000\000\000\000", __align = 21006762354147328}}, m_bTsbPdAckWakeup = true, m_RcvTsbPdStartupLock = {m_mutex = {
        __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_cbAcceptHook = {opaque = 0x0, fn = 0x0}, m_cbConnectHook = {opaque = 0x5e3f00, 
      fn = 0x4447c0 <SrtConn_ConnectCB>}, m_ConnectionLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, 
          __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
    m_SendBlockCond = {m_cv = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, 
          __nwaiters = 1, __broadcast_seq = 0}, __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", __align = 0}}, 
    m_SendBlockLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {
            __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_RcvBufferLock = {m_mutex = {__data = {
          __lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_RecvAckLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
          __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, 
---Type <return> to continue, or q <return> to quit---
    m_RecvDataCond = {m_cv = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, 
          __nwaiters = 1, __broadcast_seq = 0}, __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", __align = 0}}, 
    m_RecvLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
            __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_SendLock = {m_mutex = {__data = {__lock = 0, __count = 0, 
          __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, 
        __align = 0}}, m_RcvLossLock = {m_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, 
          __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 47 times>, __align = 0}}, m_StatsLock = {m_mutex = {__data = {
          __lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
        __size = '\000' <repeats 47 times>, __align = 0}}, m_stats = {tsStartTime = {m_timestamp = 183437909947}, sentTotal = 0, 
      sentUniqTotal = 0, recvTotal = 3377661, recvUniqTotal = 3377640, sndLossTotal = 0, rcvLossTotal = 8047, retransTotal = 0, 
      sentACKTotal = 1236900, recvACKTotal = 0, sentNAKTotal = 7, recvNAKTotal = 0, sndDropTotal = 0, rcvDropTotal = 8123, 
      bytesSentTotal = 0, bytesSentUniqTotal = 0, bytesRecvTotal = 3800572844, bytesRecvUniqTotal = 3800547840, rcvBytesLossTotal = 8839791, 
      bytesRetransTotal = 0, sndBytesDropTotal = 0, rcvBytesDropTotal = 8907658, m_rcvUndecryptTotal = 0, m_rcvBytesUndecryptTotal = 0, 
      sndFilterExtraTotal = 0, rcvFilterExtraTotal = 0, rcvFilterSupplyTotal = 0, rcvFilterLossTotal = 0, m_sndDurationTotal = 0, 
      tsLastSampleTime = {m_timestamp = 183437909947}, traceSent = 0, traceSentUniq = 0, traceRecv = 3377661, traceRecvUniq = 3377640, 
      traceSndLoss = 0, traceRcvLoss = 8047, traceRetrans = 0, sentACK = 1236900, recvACK = 0, sentNAK = 7, recvNAK = 0, traceSndDrop = 0, 
      traceRcvDrop = 8123, traceRcvRetrans = 22, traceReorderDistance = 0, traceBelatedTime = 18114437079059064, traceRcvBelated = 21, 
      traceBytesSent = 0, traceBytesSentUniq = 0, traceBytesRecv = 3800572844, traceBytesRecvUniq = 3800547840, traceRcvBytesLoss = 8839791, 
      traceBytesRetrans = 0, traceSndBytesDrop = 0, traceRcvBytesDrop = 8907658, traceRcvUndecrypt = 0, traceRcvBytesUndecrypt = 0, 
      sndFilterExtra = 0, rcvFilterExtra = 0, rcvFilterSupply = 0, rcvFilterLoss = 0, sndDuration = 0, sndDurationCounter = {
        m_timestamp = 0}}, static SELF_CLOCK_INTERVAL = 64, static SEND_LITE_ACK = 4, static PACKETPAIR_MASK = 15, m_tsFreshActivation = {
      m_timestamp = 0}, m_tsUnstableSince = {m_timestamp = 0}, m_tsWarySince = {m_timestamp = 0}, static BECAUSE_NO_REASON = 0, 
    static BECAUSE_ACK = 1, static BECAUSE_LITEACK = 2, static BECAUSE_NAKREPORT = 4, static LAST_BECAUSE_BIT = 3, 
    m_pSndQueue = 0x7fec01c9c0, m_pRcvQueue = 0x7fec01dbb0, m_PeerAddr = {{sin = {sin_family = 2, sin_port = 62758, sin_addr = {
            s_addr = 4043981066}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 2, sin6_port = 62758, 
          sin6_flowinfo = 4043981066, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 12 times>, "\177\000\000", __u6_addr16 = {0, 0, 0, 
                0, 0, 0, 127, 0}, __u6_addr32 = {0, 0, 0, 127}}}, sin6_scope_id = 10}, sa = {sa_family = 2, 
          sa_data = "&\365\nA\n\361\000\000\000\000\000\000\000"}}, len = 16}, m_piSelfIP = {3859431690, 0, 0, 0}, m_pSNode = 0x7fec01c7d0, 
    m_pRNode = 0x7fec01c7f0, m_sPollID = {_M_t = {
        _M_impl = {<std::allocator<std::_Rb_tree_node<int> >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<int> >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
            _M_color = std::_S_red, _M_parent = 0x7fec01c820, _M_left = 0x7fec01c7a0, _M_right = 0x7fec01c820}, _M_node_count = 2}}}}, 
  m_QueuedSockets = {_M_t = {
      _M_impl = {<std::allocator<std::_Rb_tree_node<int> >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<int> >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<int, int, bool>> = {<No data fields>}, <No data fields>}, _M_header = {
          _M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x7fec01c2f0, _M_right = 0x7fec01c2f0}, _M_node_count = 0}}}, m_AcceptCond = {
    m_cv = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, __nwaiters = 1, 
        __broadcast_seq = 0}, __size = '\000' <repeats 40 times>, "\001\000\000\000\000\000\000", __align = 0}}, m_AcceptLock = {m_mutex = {
      __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
      __size = '\000' <repeats 47 times>, __align = 0}}, m_uiBackLog = 0, m_iMuxID = 142218288, m_ControlLock = {m_mutex = {__data = {
        __lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
      __size = '\000' <repeats 47 times>, __align = 0}}}
(gdb)

@maxsharabayko maxsharabayko added this to the v1.4.5 milestone Oct 1, 2021
@jeandube
Copy link
Collaborator Author

jeandube commented Mar 4, 2022

Reproduced while receiving non-group stream. Problem seems to be having different threads pulling data (srt_rcvmsg2()) and pulling stats (srt_bstats()). srt_bstats() gets RcvBuffer size and timespan and can have the m_pUnit[X] it is handling get freed by the data pulling thread, causing SIGSEGV on NULL pointer. RcvBuffer is not thread safe. From the public API it seems restricted to srt_bstats() and the like vs. srt_recvXxx, but internally, many CRcvBuffer public methods have vulnerable code sections. If not fixed in the SRT lib this should at least be documented. Again the RcvBuffer state was not part of the stats in the original UDT design.

@jeandube
Copy link
Collaborator Author

jeandube commented Mar 4, 2022

Thread 54 "Stats Sampler" received signal SIGSEGV, Segmentation fault. 
[Switching to LWP 21310]
0x0000007ff6d95ff0 in DynamicStruct<unsigned int, 4ul, srt::SrtPktHeaderFields>::operator[] (this=0x0, ix=srt::SRT_PH_TIMESTAMP)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/utilities.h:381
381 /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/utilities.h: No such file or directory.
(gdb) bt
#0  0x0000007ff6d95ff0 in DynamicStruct<unsigned int, 4ul, srt::SrtPktHeaderFields>::operator[] (this=0x0, ix=srt::SRT_PH_TIMESTAMP)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/utilities.h:381
#1  0x0000007ff6df49d8 in srt::CPacket::getMsgTimeStamp (this=0x0) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/packet.cpp:482
#2  0x0000007ff6d944a4 in CRcvBuffer::getRcvDataSize (this=0x7f3400cd60, bytes=@0x7e95dfcf88: 211876, timespan=@0x7e95dfcf8c: 0)
    at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/buffer.cpp:1735
#3  0x0000007ff6db2c6c in srt::CUDT::bstats (this=0x7ea801a0c8, perf=0x7e95dfce08, clear=true, instantaneous=true) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/core.cpp:7218
#4  0x0000007ff6d7dcc8 in srt::CUDT::bstats (u=458902331, perf=0x7e95dfce08, clear=true, instantaneous=true) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/api.cpp:4306
#5  0x0000007ff6e0c39c in srt_bistats (u=458902331, perf=0x7e95dfce08, clear=1, instantaneous=1) at /home/jdube/sandbox/makito2_project/components/vendors/haisrt/srt.git/srtcore/srt_c_api.cpp:260
#6  0x0000007ff7078518 in srtcStats_PullSockRcvCtrs (srtc=0x7ea8018320, iLink=0, socku=458902331, uFlags=6) at srtc_mod.c:5143
#7  0x0000007ff707a110 in srtcStats_UpdateRcvCtrs (srtc=0x7ea8018320, uFlags=4) at srtc_mod.c:5381
#8  0x0000007ff7082288 in SrtConn_Get (mxpc=0x7ea8018320, lvl=260, opt=17039396, val_p=0x7e95dfd808, valsz_p=0x7e95dfd800) at srtc_mod.c:7072
#9  0x0000007ff7093260 in SrtConn_StatsSampler (ctlblk=0x7ea802f888, ssf=0x7ea802f6f0, rec_period=5) at srtc_stats.c:841
#10 0x0000007ff6c660a4 in StatsSmpFile_Sample (ssfile=0x7ea802f6f0, rec_period=5) at statssmp.c:1143
#11 0x0000007ff6c62f4c in statsSampler_Thread (hss=0x7ea802f660) at stats_sampler.c:99
#12 0x0000007ff7facfd8 in ?? () from /lib/libpthread.so.0
#13 0x0000007e9e5fd4e8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

@jeandube
Copy link
Collaborator Author

jeandube commented Mar 4, 2022

I found that public API access to some CRcvBuffer vulnerable methods provided via the getOpt() API (SRTO_EVENT, SRTO_RCVDATA). Maybe this issue title should be revised to SIGSEGV if pulling stats while receiving stream.

@ethouris
Copy link
Collaborator

ethouris commented Mar 4, 2022

I'd say more - that was never part of the stats to retrieve this value and was introduced with the instantaneous stats. The receiver buffer wasn't mutex-protected according to the UDT design because it was stated that it's a queue that in worst case in a pull operation won't pull an element from the queue even if it is available, but will never ride over the end of queue. But this means that only defined operations are thread safe on it and moreover some of the single operations are mutex-protected.

I think the best and safest way to fix it would be to have an extra field that keeps this value (similar as the m_mavg field) that will be keeping the last updated value. Of course, both these fields should be atomic.

@ethouris
Copy link
Collaborator

ethouris commented Mar 4, 2022

As for vulnerabilities from within getOpt, I can see only two calls. One is under a lock (that's even a cascade of about 3 locks) and one is only calculating number out of integer fields. That first one might require more analysis, but that's actually part of the original UDT (just slightly refactored in SRT). The second one may at worst return a stupid value, that's all.

@jeandube
Copy link
Collaborator Author

jeandube commented Mar 4, 2022

@ethouris maintaining the RcvBuffer size while adding/pulling could probably be done at low cost and better than the apparently simpler add-another-mutex solution. Stats pulling is quite a low rate event (default 5 sec, min 1 sec in my case).

@ethouris
Copy link
Collaborator

ethouris commented Mar 4, 2022

Yeah, but that would be nontrivial. The average value is being calculated basing on the rare update events and it picks up the value from CRcvBuffer::getRcvDataSize to calculate the average. The instantaneous query requires the deep review of the buffer to find out each packet's number, size and time span.

I think the least invasive method would be to have extra stats fields in the buffer that would be updated with every operation on the buffer.

@jeandube
Copy link
Collaborator Author

jeandube commented Mar 4, 2022

agree.

@maxsharabayko
Copy link
Collaborator

Partially addressed in #2146 (v1.4.5-dev).
However, retrieving pktRcvBuf still remains unprotected.

if (m_pRcvBuffer)
{
    perf->byteAvailRcvBuf = getAvailRcvBufferSizeLock() * m_config.iMSS;
    if (instantaneous) // no need for historical API for Rcv side
    {
        perf->pktRcvBuf = m_pRcvBuffer->getRcvDataSize(perf->byteRcvBuf, perf->msRcvBuf);
    }
    else
    {
        perf->pktRcvBuf = m_pRcvBuffer->getRcvAvgDataSize(perf->byteRcvBuf, perf->msRcvBuf);
    }
}

Sadly, the same can be said about missing protection of the sender buffer.

@ethouris
Copy link
Collaborator

ethouris commented Mar 7, 2022

Yes, and adding a protection here would be then a risk for introducing deadlocks. The original UDT design for this has simply intended particular functionalities of the buffer to have particular thread affinity. This improves performance and simplifies the design (especially with regard to deadlocks), but it's a hell for improvements and extensions.

@maxsharabayko
Copy link
Collaborator

@jeandube Please feel free to reopen if the crash would still be there.

jeandube added a commit to jeandube/srt that referenced this issue Mar 10, 2022
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 Priority: High Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants