-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Worker: Fix possible double free when ICE consent check fails #1393
Worker: Fix possible double free when ICE consent check fails #1393
Conversation
@miroslavpejic85, I've not been able to reproduce the crash even by forcing things that IMHO should trigger the crash. Anyway, I think that this PR is gonna fix it. Is it possible that you try this branch and confirm whether it solves the crash or not? |
This flow is super complex but it's what it is: When calling
Problem is [A] since it ends calling |
Sure, I need to reconstruct the worker on this branch and give it a try right? cd worker; MEDIASOUP_BUILDTYPE='Debug' make |
Yes. Or just add a git url pointing to this branch as mediasoup dependency in the package.json of your server app and run "npm install mediasoup". |
Note: The crash occurs despite not utilizing the |
The fix in this PR is not related to WebRtcServer so it may be valid (assuming in doesn't crash anymore for you once you try the branch). |
Great, then I'll try the fix and keep you updated. |
I think this can happen wherever
What the iterator will point to? This will either crash, or destroy some extra tuple. In |
It's indeed crashing but not sure why. This was done and tested long ago, not sure what has changed. I've just set
However I think it crashes because the code assumes that
Why do you think it will crash? The comment above it clearly indicates what it does: // Notify the listener.
this->listener->OnIceServerTupleRemoved(this, removedTuple);
// Remove it from the list of tuples.
// NOTE: Do it after notifying the listener since the listener may need to
// use/read the tuple being removed so we cannot free it yet.
// NOTE: This trick is needed since it is a reverse_iterator and
// erase() requires a iterator, const_iterator or bidirectional_iterator.
this->tuples.erase(std::next(it).base());
I also expected this to happen, but for whatever reason it doesn't (or I couldn't reproduce it). But I agree that it makes sense that we block reenter of |
@snnz I've done it in last commit, can you check? |
Because
Everything is ok now, I believe this will fix the problem. |
While this PR fixes this I still don't understand why (before this PR) we didn't get an infinite loop. You say that it will stop recursively calling itself because the connection is closed, but we do not check if the connection is closed anywhere (if closed it should be deleted or being deleted). Well, now that I think about it I just removed that check in a recent related PR. Anyway I think everything is ok now. |
But there is a check, in
|
True. |
@miroslavpejic85 any ETA for you to test this branch? After the discussion above it's clear that these changes make sense and I'd like to release ASAP, but having your ok would be great. |
@ibc Everything seems to be running smoothly now, without any worker crashes since yesterday. You can go ahead and release it. Thank you! |
Thanks a lot! |
You're welcome! And thank you for addressing the issue promptly ;) |
Fixes #1392