Haivision / srt

Secure, Reliable, Transport
https://www.srtalliance.org
Mozilla Public License 2.0
3.11k stars 852 forks source link

[Epic] Rework Receiver Buffer #1674

Closed maxsharabayko closed 3 years ago

maxsharabayko commented 3 years ago

Motivation

The current implementation of the receiver buffer has several disadvantages.

TODO

Preparational Changes

Receiver Buffer Functionality

Protecting Concurrent Access

alexpokotilo commented 3 years ago

Hi again Max!

we faced with following panic related to CRcvBuffer

        /usr/bin/nimble(_Z14signal_handleri+0x71) [0x5684b1]
        /lib64/libpthread.so.0(+0xf630) [0x7fa2e47d5630]
        /lib64/libc.so.6(gsignal+0x37) [0x7fa2e3074387]
        /lib64/libc.so.6(abort+0x148) [0x7fa2e3075a78]
        /lib64/libc.so.6(+0x78ed7) [0x7fa2e30b6ed7]
        /lib64/libc.so.6(+0x81299) [0x7fa2e30bf299]
        /lib64/libsrt-nimble.so.1(_ZN10CRcvBufferD1Ev+0x46) [0x7fa2da3d0106]
        /lib64/libsrt-nimble.so.1(_ZN4CUDTD1Ev+0xa0) [0x7fa2da3e06a0]
        /lib64/libsrt-nimble.so.1(_ZN10CUDTSocketD1Ev+0x1c) [0x7fa2da3c623c]
        /lib64/libsrt-nimble.so.1(_ZN10CUDTUnited12removeSocketEi+0x2d9) [0x7fa2da3c8739]
        /lib64/libsrt-nimble.so.1(_ZN10CUDTUnited18checkBrokenSocketsEv+0x4fa) [0x7fa2da3c924a]
        /lib64/libsrt-nimble.so.1(_ZN10CUDTUnited14garbageCollectEPv+0x50) [0x7fa2da3c9370]
        /lib64/libpthread.so.0(+0x7ea5) [0x7fa2e47cdea5]
        /lib64/libc.so.6(clone+0x6d) [0x7fa2e313c96d]

it's very similar to https://github.com/Haivision/srt/issues/1604 as this panic is in destructor of CRcvBuffer and it's inside delete[] m_pUnit; So my guess is that some code in CRcvBuffer in writing into m_pUnit[-1]. there are some playing with "-1" indexes in

I've made a stupid fix adding additional element to m_pUnit and move pointer to the next element so that m_pUnit[-1] will not lead to panic in destructor. I'll reply if this fix helps. But I think we have m_pUnit[-1] access problem with CRcvBuffer. I cannot reproduce this problem myself unfortunately

maxsharabayko commented 3 years ago

Hi @alexpokotilo Could you please submit a dedicated GitHub issue for this crash? And the proposed fix. Even if it is not very accurate, it may still be a good start.

alexpokotilo commented 3 years ago

Hi @maxsharabayko, done I wish I have more info right now. I'll post new findings there

maxsharabayko commented 3 years ago

Resolved by PR #1964.