Address issue #716 by zero initializing pointers and freeing memory#717
Address issue #716 by zero initializing pointers and freeing memory#717
Conversation
Signed-off-by: Stephen Brawner <brawner@gmail.com>
|
Addresses #716 |
| // 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"); |
There was a problem hiding this comment.
This might be overwritten by https://github.com/ros2/rcl/pull/717/files?file-filters%5B%5D=.c#diff-1f30210b7875b9b39020ed2b9c12bd78L173
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.
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.
|
I got the go-ahead privately from @jacobperron to merge with Dirk's approval |
) (#820) Signed-off-by: Stephen Brawner <brawner@gmail.com>
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