-
Notifications
You must be signed in to change notification settings - Fork 16
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
Not use emplace for editing vector elements #143
Conversation
@@ -33,7 +33,7 @@ class MessageEndpoint | |||
MessageEndpoint(const std::string& hostIn, int portIn, int timeoutMsIn); | |||
|
|||
// Delete assignment and copy-constructor as we need to be very careful with | |||
// socping and same-thread instantiation | |||
// scoping and same-thread instantiation |
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.
Caught this re-visiting the sources so figured out i'd just change it.
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.
Good catch. With bugs like this it's good to add a test that would have failed before, but now passes (if possible). In this case perhaps it could combine calls to initRemoteMpiEndpoint
and getUnackedMessageBuffer
to check that things work?
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.
Nice work on the tests. I've added some comments about how I don't think we need to mark them as test-only or throw exceptions, so once that stuff's been removed I think it's good to go.
Pretty simple, silly, yet nasty bug with the MPI implementation.
In two different
std::vector
s (which we previously filled byemplace_back
-ingnullptr
s, we usedemplace(<offset>, <thing to be moved>)
to modify the element at offset<offset>
.Turns out that this is not how
emplace
works. Citing cppreference:Thus, our vector elements were moved all around the place in a non-deterministic manner. The fact that this worked sometimes is because:
This would have worsen dramatically with more aggressive testing or different rank-host distributions. I checked, and this does not happen anywhere else in the codebase.
Should have read the reference better before hand.