-
Notifications
You must be signed in to change notification settings - Fork 28
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
Memory leak from enclave #311
Comments
Here is a MWE. It's a silly program that doesn't accomplish anything other than to demonstrate this problem, but when I use valgrind I get the following results:
This suggests that it is the |
@jimmy-mcelwain thanks for recreating the issue here, this does seem like a problem. |
I would need to check this deeper but the for of In any case, I wonder why |
we understand. But seeing as
That is also something I'm not sure about. Perhaps @clalancette and/or @fujitatomoya can say something about that. |
Honestly, this seems like a bug in To fix it, we have to either:
I would actually probably go for the latter; while it is annoying to have to duplicate that code among the various RMWs, I think it also makes more sense since this code is manipulating the |
yeah, thanks for pointing this out, i focused on memory leak issue. this is not good. the thing is that some data of
i am also inclined to this option, it is important to keep the clear responsibility for memory management for maintenance. @clalancette i can patch this if we are good to go. i can also give it a shot to |
@fujitatomoya that's it. I guess that checking if When this responsibility is moved to rmw implementations, the correct option is not to allocate nor deallocate this as rmw_microxrcedds does not handle SROS2 security features. |
@fujitatomoya thank you, I appreciate it! Are these changes expected to be backported and added to future humble and jazzy releases? Or is this change likely just for future ROS2 distributions? |
No i do not think so. rolling fix adds the new interfaces, so unlikely backported to already released distro. let me see how jazzy and humble can be fixed. |
Describe the bug
Context ros2/rcl#1198 and Yaskawa-Global/motoros2#35
I believe that there is a possible memory leak in rmw_microxrcedds. In the micro-ROS rcl repo, the following lines duplicate a string and dynamically allocate the memory if
RCL_MICROROS_COMPLETE_IMPL
is set.https://github.com/micro-ROS/rcl/blob/041a67a2e102e9c48ae2580f19b2677016fcf86a/rcl/src/rcl/init.c#L265-L273
This memory which is dynamically allocated for
enclave
viarcutils_strdup
is deallocated in other (full) rmw implementations. For example:https://github.com/ros2/rmw_fastrtps/blob/1128b57d336dfa8bf462a5f9147291f73faa8ed3/rmw_fastrtps_shared_cpp/src/rmw_init.cpp#L116
However it is never deallocated in rmw_microxrcedds. I believe that this is only a problem if
RCL_MICROROS_COMPLETE_IMPL
is set, because that is the only case wherercutils_strdup
runs and sets aside dynamic memory.I do not believe that the solution is as simple as freeing the memory in
rmw_init_options_fini
, because the code below copies theenclave
data to static memory, and thus cannot be freed. I might be wrong about that.https://github.com/micro-ROS/rcl/blob/041a67a2e102e9c48ae2580f19b2677016fcf86a/rcl/src/rcl/init.c#L105-L110
To Reproduce
I do not have a MWE, but it is apparent in MotoROS2 using the debug listener script.edit - I have a MWE belowExpected behaviour
I expect the memory set aside by
rcutils_strdup
to be freed by the rmw, as it is with other rmws.System information (please complete the following information):
Please let me know if I need to provide any more information, or if I am doing something improperly. Thank you.
The text was updated successfully, but these errors were encountered: