Address issue #716 by zero initializing pointers and freeing memory#717
Merged
Address issue #716 by zero initializing pointers and freeing memory#717
Conversation
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Contributor
Author
Contributor
Author
|
Addresses #716 |
dirk-thomas
approved these changes
Jul 15, 2020
| // Copy action client name and options. | ||
| action_client->impl->action_name = rcutils_strdup(action_name, allocator); | ||
| if (NULL == action_client->impl->action_name) { | ||
| RCL_SET_ERROR_MSG("failed to duplicate action name"); |
Collaborator
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
Are there any specific circumstances you are worried about? Setting impl to get the zero_initialized values should put the object into a known state, which helps ensure cleanup occurs predictably. Otherwise if there is a double error, then it can be helpful for the message to be set twice, so that the log file has a record of the sequence of events that failed.
Collaborator
There was a problem hiding this comment.
Actually no, but there's been discussion about this, #713 (comment). I do not think that this is the problem but status. I'd think it might be better to share.
Contributor
Author
|
I got the go-ahead privately from @jacobperron to merge with Dirk's approval |
brawner
added a commit
that referenced
this pull request
Oct 5, 2020
) (#820) Signed-off-by: Stephen Brawner <brawner@gmail.com>
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.
During initialization of
rcl_action_client, pointers were not explicitly zero initialized which was only an issue ifrcl_action_client_initfailed at some point and then tried to cleanup in its fail block. This was only pointed out in an error on Windows debug, as an unitialized pointer was checked for null. This exact sort of initialization failure was added in a unit test in #663. Furthermore, because the action_client was invalid in the fail block, cleanup would subsequently fail.Example of windows Debug failure
https://ci.ros2.org/view/nightly/job/nightly_win_deb/1682/testReport/(root)/projectroot/test_action_client_2/
This PR zero initialized
rcl_action_client_impl_tonce it's allocated and adds a_rcl_action_client_fini_impland uses that for cleanup inrcl_action_client_initinstead.Fixes #716
I checked these changes with
test_action_clientand valgrind, which resulted only in the unrelated error below.Signed-off-by: Stephen Brawner brawner@gmail.com