-
-
Notifications
You must be signed in to change notification settings - Fork 474
call resetcallbacks only after triggerClosed #1384
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
Conversation
|
As I see same thing could happen to Track also. |
|
Oops... Very rare but still there is a race condition.
The solution seems to guard the close function totally. If you also confirm that, I can create a PR for it. |
This scenario is not possible because the destructor can only be called if all shared pointers have been deleted, whereas the thread calling close must hold a shared pointer. |
paullouisageneau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks fine to me, thank you for the investigation!
|
As I said it is scarce but I see it still. With these changes; If I guard the close function, the problem is solved. |
|
A thread calling the destructor while another thread is in a method should never happen. Are you sure the two calls are for the same datachannel? If it happens, this is a memory issue related to smart pointers. Guarding the destructor would not be a proper workaround because it means a thread might destroy the mutex while another thread waits on it. |
|
I was running the test program only for 1 data channel. As I meant/wrote, guard for data channel close function not destructor. |
So are you sure the log for one peer is not interleaved with the log for the other?
Sorry my bad, I meant guarding the close function. It wouldn't mitigate the core issue that one thread destroys an object while the other is in a method. |
I will add peer ids to log, when I have time
That’s true, will not solve root problem |
|
If the problem is really related to a shared_ptr bug maybe we have to find guard any other workaround. let’s run the test and have logs with peer ids |
|
Logs with peer IDs. |
|
And logs for a normal run, no error |
|
Please check this PR Since you are also closing the channels on With this PR also no problem. |
|
And now log is more clean (for 1 datachannel) |
|
OK, it makes sense, even if I'm not sure I understand what was the underlying issue. |
|
Could you please create a tag or release for this? |
|
@paullouisageneau Could you please create a release for this fix? |
|
@murat-dogan @mertushka I've released v0.23.0 with the fix. |
Sometimes resetting close callback before calling it.
Related issue:
murat-dogan/node-datachannel#349
I have modified this code part like this, in order to catch the race condition:
This is a normal call, without race condition:
This is the output when a race condition occurs:
This solution is working.
Another solution could be that, we can guard this part of the code .