-
Notifications
You must be signed in to change notification settings - Fork 321
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 flaky tests caused by relaxed load in C++ 'shared_ptr::use_count()' #450
Conversation
* The `Default` trait did not actually get derived for `SharedPtr<T>`. This is solved by implementing `Default` manually. * Trait function `Shared::get()` used to return a mutable raw pointer (`*mut Self`), but it would be inconceivable to ever mutate the referenced value. It was changed to return a const pointer instead. * Added some basic unit tests for types `SharedPtr` and `SharedRef`.
shared_ptr::use_count()
relaxed load
shared_ptr::use_count()
relaxed load
Are we even using shared_ptr in a multithreaded way? I don't really understand what is happening here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - but consider removing assert_use_count_eq from the public API
Theoretically the thread could be preempted, or a page fault could happen, in between dropping the My alternative theory is that this is what SPECTRE mitigation looks like. @bnoordhuis I wonder if you have any theories... |
* The `Default` trait did not actually get derived for `SharedPtr<T>`. This is solved by implementing `Default` manually. * Trait function `Shared::get()` used to return a mutable raw pointer (`*mut Self`), but it would be inconceivable to ever mutate the referenced value. It was changed to return a const pointer instead. * Added some basic unit tests for types `SharedPtr` and `SharedRef`.
No description provided.