You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found the behavior of microros_allocate() is inconsistent with RCL's default allocator implementation malloc(). When allocating zero size memory area, microros_allocate() returns NULL while malloc() (on Linux) returns a valid memory address.
I encounter this problem when trying to turn on RCL_COMMAND_LINE_ENABLED. I pass an empty commandline argument into rclc_support_init() (argc = 1, argv = {""}), and then ROS crashes at rcl_init because it tries to allocate 0 byte memory.
The workaround is quite simple: just allocate at least 1 byte in microros_allocate() if requested size is 0. However, in the manual of malloc(), it says:
NULL may also be returned by a successful call to malloc() with a size of zero, or by a successful call to calloc() with nmemb or size equal to zero.
I'm not sure whether it's a micro-ROS's bug or RCL's bug.
The text was updated successfully, but these errors were encountered:
I guess that we comply with malloc() functionality. As far as we try to save as much memory as possible in the micro-ROS stack, maybe is better to fix the RCL code to handle the NULL return in the CLI parsing.
I found the behavior of
microros_allocate()
is inconsistent with RCL's default allocator implementationmalloc()
. When allocating zero size memory area,microros_allocate()
returnsNULL
whilemalloc()
(on Linux) returns a valid memory address.I encounter this problem when trying to turn on
RCL_COMMAND_LINE_ENABLED
. I pass an empty commandline argument intorclc_support_init()
(argc = 1, argv = {""}
), and then ROS crashes atrcl_init
because it tries to allocate 0 byte memory.The workaround is quite simple: just allocate at least 1 byte in
microros_allocate()
if requested size is 0. However, in the manual ofmalloc()
, it says:I'm not sure whether it's a micro-ROS's bug or RCL's bug.
The text was updated successfully, but these errors were encountered: