-
Notifications
You must be signed in to change notification settings - Fork 155
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 task's move constructor #371
Fix task's move constructor #371
Conversation
a02070b
to
06d5370
Compare
Running |
@@ -77,7 +77,6 @@ TaskPrivate::TaskPrivate(Task* me, const std::string& ns) | |||
TaskPrivate& TaskPrivate::operator=(TaskPrivate&& other) { | |||
this->WrapperBasePrivate::operator=(std::move(other)); | |||
ns_ = std::move(other.ns_); | |||
introspection_ = std::move(other.introspection_); |
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.
Maybe I should reset other.introspection_
?
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.
Moving a unique_ptr
like this should correctly reset other's introspection_ pointer.
Thanks to the Address sanitizer, I was able to fix the bug, introspection hold a pointer to a PrivateTask so when we move the lhs the moved introspection will still point to the deleted task_ causing any call to introspection to access freed memory
|
Codecov Report
@@ Coverage Diff @@
## master #371 +/- ##
==========================================
+ Coverage 54.55% 54.61% +0.06%
==========================================
Files 102 102
Lines 7852 7851 -1
==========================================
+ Hits 4283 4287 +4
+ Misses 3569 3564 -5
Continue to review full report at Codecov.
|
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.
From my point of view, the issue is not related to the introspection pointer, but to the list of children not correctly moved. This definitely needs deeper inspection, but I need to finish for today.
@@ -77,7 +77,6 @@ TaskPrivate::TaskPrivate(Task* me, const std::string& ns) | |||
TaskPrivate& TaskPrivate::operator=(TaskPrivate&& other) { | |||
this->WrapperBasePrivate::operator=(std::move(other)); | |||
ns_ = std::move(other.ns_); | |||
introspection_ = std::move(other.introspection_); |
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.
Moving a unique_ptr
like this should correctly reset other's introspection_ pointer.
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.
Thanks, @JafarAbdi, for tracking this down. Your solution to keep the existing introspection instance was correct in principle. However, if the other task doesn't have introspection enable, we should disable it in the new instance too and vice versa. I added a corresponding fixup.
* Add unit test * Fix TaskPrivate's move assignment operator * Slightly simplify code Co-authored-by: Robert Haschke <[email protected]>
* Add unit test * Fix TaskPrivate's move assignment operator * Slightly simplify code Co-authored-by: Robert Haschke <[email protected]>
Fix moveit/moveit2_tutorials#426
Backtrace: