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 data races in VersionManager #6411

Merged
merged 1 commit into from
Mar 29, 2023
Merged

Fix data races in VersionManager #6411

merged 1 commit into from
Mar 29, 2023

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Mar 22, 2023

Access to m_info was not guarded by a lock, so one thread could potentially remap it while another thread was reading from it. TSan sometimes catches this running the Swift tests.

CHANGELOG.md Outdated
@@ -6,6 +6,7 @@

### Fixed
* `SyncSession::pause()` could hold a reference to the database open after shutting down the sync session, preventing users from being able to delete the realm. ([#6372](https://github.com/realm/realm-core/issues/6372), since v13.3.0)
* Fix a data race in `DB::VersionManager`. If one thread committed a write transaction which increased the number of live versions above the previous highest seen during the current session at the same time as another thread began a read, the reading thread could read from a no-longer-valid memory mapping ([PR #6411](https://github.com/realm/realm-core/pull/6411), since v13.0.0).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could end users experience this? @tgoyne could this be rephrased in end user terms that could easily be put in the SDK release notes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a data race detected by tsan, not something we observed functional problems from. I have no idea what would happen when the race is hit other than that it'd be bad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, then maybe we should add. "This hasn't been reported by any users" or similar?

Copy link
Contributor

@finnschiermer finnschiermer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Access to `m_info` was not guarded by a lock, so one thread could potentially
remap it while another thread was reading from it.
@tgoyne tgoyne merged commit 24bb03a into master Mar 29, 2023
@tgoyne tgoyne deleted the tg/version-manager-race branch March 29, 2023 16:43
@dlbuckley dlbuckley mentioned this pull request May 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants