-
Notifications
You must be signed in to change notification settings - Fork 101
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
avoid dynamic memory allocation during error handling #121
Conversation
…tion Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Here's the first "downstream" pull request due to these API changes: ros2/rmw#153 |
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
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.
Overall, I like the change. This initial review has some details that I came across, plus a couple of questions. I can do a bit more reviewing for it later.
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
…mptions Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
The only test failure was due to the launch problem. Also the job is marked as failing, but the job finished (no compiler error). @mjcarroll |
This is waiting on ros2/launch#153 to have clean CI, but otherwise I believe CI is good for this set of pull requests and ready for review. |
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.
Some minor comments, but LGTM pending CI.
Signed-off-by: William Woodall <william@osrfoundation.org>
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.
Minor comments, feel free to ignore
Signed-off-by: William Woodall <william@osrfoundation.org>
Signed-off-by: William Woodall <william@osrfoundation.org>
Ok I think I addressed all of the feedback, can you guys give it a another look. |
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
Ok, I'm going to take my window to merge. I'm happy to follow up with changes in new pr's if needed. |
This pull request refactors the way the error handling API in rcutils works so that it does not use dynamic memory and there does not need an allocator in most cases and also should make it easier to use in real-time and high performance situations.
Overview of major changes:
rcutils_error_state_t
now uses fixed length stringsrcutils_get_error_string()
) returns a fixed sized stringrcutils_get_error_string_safe()
as you cannot get a nullptr for the error string anymore (so it's always "safe")rcutils_initialize_error_handling_thread_local_storage
is required to be called in new threads in order to avoid memory allocations in other functionsosrf_testing_tools_cpp
.Main migration issues:
rcutils_get_error_string_safe()
will need to change torcutils_get_error_string().str
(so long as the temporary is ok)rcutils_error_string_t copy = rcutils_get_error_string();
)RCUTILS_SET_ERROR_MSG("char array has no valid allocator", error_msg_allocator);
->RCUTILS_SET_ERROR_MSG("char array has no valid allocator");
These changes are annoying, but I think ultimately they're for the better. I considered keeping existing signatures and doing tick-tock, and that's an option of the macro's which take allocators, but not so for the get error string signature, since it needs to return the copy to the fixed sized string. I decided against doing it for the macros because it would require using a separate name for the new macros and because deprecating them is not easy in pure C.
I have a lot more changes up and down the stack due to these API changes, and I'll open pull requests for those once I get feedback on the proposed changes here.
/cc @serge-nikulin fyi