[core] fix race crash for m_RecvDataLock on shutdown #1606
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We identified a problem in 1.4.2 on Windows (although likely topical on all platforms).
If a session does not establish before being stopped, then a crash can happen within the SRT library. This was identified internally as a race condition. Specifically, in the following function:
Above, there is a join under m_RecvDataLock mutex, but when this thread is started in "int CUDT::processData(CUnit* in_unit)" there is no lock.
This PR adds a fix to this problem by introducing a scoped lock within the call to CUDT::processData.
This may not be the perfect way to fix -- maybe it should be another mutex dedicated for this thread. There may be other race conditions, but we think this small change should not cause terrible problems and certainly does stop crashes when a client might connect and then abort before completing a session.
It should be noted, I'm acting as somewhat of a puppet for the engineer that analyzed and patched this - so my responses might be slower than normal.