amazon-kinesis-video-streams-webrtc-sdk-c icon indicating copy to clipboard operation
amazon-kinesis-video-streams-webrtc-sdk-c copied to clipboard

Fix T-San Data Race Issues

Open stefankiesz opened this issue 1 year ago • 1 comments

Issue #, if available:

What was changed?

  • Corrected thread synchronization to prevent unsafe access to shared variables across threads.
  • Added missing resetting of pConnectionListener->receiveDataRoutine to INVALID_TID_VALUE.
  • Fixed RollingBuffer lastIndex race.
  • Note: This one only appeared as a T-San warning when I ran the sample myself and connected/disconnected viewer several times - issue did not show when I ran the test suite.

Why was it changed?

  • In order to resolve Thread Sanitizer failures.
    • The failures are intermittent on the CI tests - re-running several times will eventually yield passing results.
    • The failures are consistently present when running locally on macOS with LLDB.

How was it changed?

  • Added missing mutex locks around asynchronous accessing of variables.
  • Set the receiveDataRoutine to INVALID_TID_VALUE whenever THREAD_JOIN is called on its thread. This was done for the IS_VALID_TID_VALUE check to actually be able to check for whether THREAD_JOIN was already called on the thread.
  • Wrapped access to pRollingBuffer->lastIndex within the pRollingBuffer->lock.

What testing was done for the changes?

  • Ran the test suite locally on Mac with T-San enabled in Debug mode.
  • Let the CI to pass 3 times in a row to check for intermittent issues.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

stefankiesz avatar Nov 12 '24 05:11 stefankiesz

This is a very old issue. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to open a new one.

github-actions[bot] avatar Jun 16 '25 00:06 github-actions[bot]