ultravideo / uvgRTP

An open-source library for RTP/SRTP media delivery
BSD 2-Clause "Simplified" License
325 stars 92 forks source link

bug in reception_flow.cc #214

Open wowaser opened 8 months ago

wowaser commented 8 months ago

Hello,

I have encountered a read access violation while re-initializing my object that holds the uvgrtp functionality. Here's my debugger view: image

As you can see handlers has been invalidated. I suspect that some other thread calls reception_flow::clear_stream_from_flow which erases from packet_handlers, thus invalidating the pointer. There is no mutex protecting from such occurrence, only a check if (handlers != nullptr), but there is no protection from invalidation after that check.

Unfortunately I don't have a reliable way to reproduce this issue. Hopefully the info I provided is enough :)

Thanks!

tampsa commented 7 months ago

Hello,

Sorry to hear that you are experiencing this issue. Some more information on the situation would make it easier for us to debug this. Do you have several sessions inside the uvgRTP context, or several media streams inside the session? Are you deleting and re-creating the context, session or media stream? A description of the situation or code that triggers this bug would be helpful.

-Heikki

wowaser commented 7 months ago

Hello,

I have 1 session with multiple streams. When I re-create my object, I call destroy_session(my_session) and the context just goes out of scope. I want to clarify, that this error does not happen every time I delete my object.

jrsnen commented 7 months ago

Hi,

@wowaser is it so that you continue sending and at the same time you close the session? I'm guessing we haven't tested this scenario much, and there is a moment when the receiver is in an invalid state.

This bug seems something that should be fixed at some point when either me or @tampsa has the time.

BR, Joni