Skip to content
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

Correctly clean up arguments structure. #459

Merged
merged 5 commits into from
Apr 11, 2018
Merged

Correctly clean up arguments structure. #459

merged 5 commits into from
Apr 11, 2018

Conversation

mjcarroll
Copy link
Member

@mjcarroll mjcarroll commented Apr 5, 2018

Clean up the arguments structure, which was previously leaking.

Connects to #458

@mjcarroll mjcarroll self-assigned this Apr 5, 2018
@mjcarroll mjcarroll requested a review from sloretz April 5, 2018 19:29
@mjcarroll mjcarroll added the in progress Actively being worked on (Kanban column) label Apr 5, 2018
// Not using throw_from_rcl_error, because we may need to append deallocation failures.
exceptions::RCLErrorBase base_exec(ret, rcl_get_error_state());
rcl_reset_error();
if (RCL_RET_OK != rcl_arguments_fini(&parsed_args)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like rcl_parse_arguments cleans up after itself when something goes wrong. I would expect this call to rcl_arguments_fini to always fail here.

@mjcarroll mjcarroll added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Apr 5, 2018
Copy link
Contributor

@sloretz sloretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with green CI

@@ -241,6 +250,11 @@ rclcpp::remove_ros_arguments(int argc, char const * const argv[])
alloc.deallocate(nonros_argv, alloc.state);
}

ret = rcl_arguments_fini(&parsed_args);
if (RCL_RET_OK != ret) {
exceptions::throw_from_rcl_error(ret, "failed to cleanup parsed arguments, leaking memory: ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the : needed in this case? I think this adds it automatically:

formated_prefix += ": ";

rcl_get_error_string_safe();
rcl_reset_error();
}
throw base_exec;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our default behaviour is to throw an RCLError not an RCLErrorBase. I would change this to

throw RCLError(base_exc, "");

following
https://github.com/ros2/rclcpp/blob/c70f2f145239ca4dfe86c6d806f331602a0e5c68/rclcpp/src/rclcpp/exceptions.cpp#L71..L72

@@ -224,10 +224,19 @@ rclcpp::remove_ros_arguments(int argc, char const * const argv[])
&nonros_argv);

if (RCL_RET_OK != ret) {
// Not using throw_from_rcl_error, because we may need to append deallocation failures.
exceptions::RCLErrorBase base_exec(ret, rcl_get_error_state());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless it's a convention that I haven't seen before, exec doesn't seem like an appropriate variable name (base_exc instead?)

@mjcarroll mjcarroll merged commit 07e5be7 into master Apr 11, 2018
@mjcarroll mjcarroll deleted the fix_issue_458 branch April 11, 2018 17:43
@mjcarroll mjcarroll removed the in review Waiting for review (Kanban column) label Apr 11, 2018
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
* Add graph test for service clients

There were tests for publishers, subscriptions, and services, but not clients.

Signed-off-by: Jacob Perron <[email protected]>

* Add function for getting clients by node

Signed-off-by: Jacob Perron <[email protected]>

* Update service client graph test

Signed-off-by: Jacob Perron <[email protected]>

* Fix doc sentence

Signed-off-by: Jacob Perron <[email protected]>

* Update docs

Signed-off-by: Jacob Perron <[email protected]>
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* Consolidate ZSTD utility functions

The zstd_compressor and zstd_decompressor implementations had a
number of duplicated utility functions between them; this consolidates
them into one file.

Signed-off-by: P. J. Reed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants