Fix data race - #498
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #498 +/- ##
==========================================
- Coverage 76.91% 76.79% -0.12%
==========================================
Files 113 113
Lines 6048 6056 +8
Branches 2640 2644 +4
==========================================
- Hits 4652 4651 -1
- Misses 1060 1071 +11
+ Partials 336 334 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 98549a8. Configure here.
Returning shared pointers to the actual buffers is a risk with regards to thread safety. It would probably be even better to use std::optional as an interface for all of them, but since we've established the shared pointer interface already, this is imho the next best thing.
urrsk
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

While reviewing #496 I realized that we access data from the primary consumer in a hazardous way: Data is stored in shared pointers, while writing and reading those shared pointers is mutex-protected inside the consumer. However, the public access functions expose those shared pointers directly.
This PR instead exposes copies of the buffers upon request.
Note
Medium Risk
Changes thread-safety semantics in
PrimaryConsumerby no longer exposing internal shared state and by altering ownership/storage types, which could impact performance or expectations around pointer identity/lifetime.Overview
PrimaryConsumerno longer exposes its internally-updated state via shared pointers that can be read/written concurrently.Incoming primary packages are now stored as
unique_ptr(andstd::optionalforVersionInformation), and the publicget*accessors return fresh copies (ornullptrwhen unset) instead of the internal pointer, eliminating a potential data race when callers access data outside the consumer’s mutexes.Reviewed by Cursor Bugbot for commit d390052. Bugbot is set up for automated code reviews on this repo. Configure here.