-
Notifications
You must be signed in to change notification settings - Fork 422
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
Conversation
rclcpp/src/rclcpp/utilities.cpp
Outdated
// 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)) { |
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.
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.
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.
LGTM with green CI
rclcpp/src/rclcpp/utilities.cpp
Outdated
@@ -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: "); |
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.
Is the :
needed in this case? I think this adds it automatically:
rclcpp/rclcpp/src/rclcpp/exceptions.cpp
Line 60 in 45dcd0c
formated_prefix += ": "; |
rclcpp/src/rclcpp/utilities.cpp
Outdated
rcl_get_error_string_safe(); | ||
rcl_reset_error(); | ||
} | ||
throw base_exec; |
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.
I think our default behaviour is to throw an RCLError
not an RCLErrorBase
. I would change this to
throw RCLError(base_exc, "");
rclcpp/src/rclcpp/utilities.cpp
Outdated
@@ -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()); |
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.
unless it's a convention that I haven't seen before, exec
doesn't seem like an appropriate variable name (base_exc
instead?)
* 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]>
* 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]>
Clean up the arguments structure, which was previously leaking.
Connects to #458