Skip to content
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

Fix T-San Data Race Issues #2078

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft

Fix T-San Data Race Issues #2078

wants to merge 8 commits into from

Conversation

stefankiesz
Copy link
Contributor

@stefankiesz stefankiesz commented Nov 12, 2024

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 stefankiesz changed the title Fix TSAN errors Fix T-San Data Race Issues Nov 12, 2024
@stefankiesz stefankiesz marked this pull request as draft November 12, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant