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

UB: memcpy with overlapping memory in rcutils_array_list_remove when destroying child logger during tear down #433

Closed
tylerjw opened this issue Nov 3, 2023 · 0 comments · Fixed by #434

Comments

@tylerjw
Copy link
Contributor

tylerjw commented Nov 3, 2023

This is test output from mtc with asan.

    [moveit_task_constructor_core-test-move-to-1] ==6030==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x60300033e200,0x60300033e210) and [0x60300033e208, 0x60300033e218) overlap
    [moveit_task_constructor_core-test-move-to-1]     #0 0x7f8c9d26d1ed in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
    [moveit_task_constructor_core-test-move-to-1]     #1 0x7f8c9d121322 in rcutils_array_list_remove (/opt/ros/rolling/lib/librcutils.so+0x7322)
    [moveit_task_constructor_core-test-move-to-1]     #2 0x7f8c9d122cbd in rcutils_hash_map_unset (/opt/ros/rolling/lib/librcutils.so+0x8cbd)
    [moveit_task_constructor_core-test-move-to-1]     #3 0x7f8c9a6bd286  (/opt/ros/rolling/lib/librcl.so+0x1a286)
    [moveit_task_constructor_core-test-move-to-1]     #4 0x7f8c9a6c2459 in rcl_logging_rosout_fini_publisher_for_node (/opt/ros/rolling/lib/librcl.so+0x1f459)
    [moveit_task_constructor_core-test-move-to-1]     #5 0x7f8c9c7935cb  (/opt/ros/rolling/lib/librclcpp.so+0x12e5cb)
    [moveit_task_constructor_core-test-move-to-1]     #6 0x7f8c9c798167  (/opt/ros/rolling/lib/librclcpp.so+0x133167)
    [moveit_task_constructor_core-test-move-to-1]     #7 0x7f8c9c7568c9  (/opt/ros/rolling/lib/librclcpp.so+0xf18c9)
    [moveit_task_constructor_core-test-move-to-1]     #8 0x7f8c9c790426 in rclcpp::node_interfaces::NodeBase::~NodeBase() (/opt/ros/rolling/lib/librclcpp.so+0x12b426)

My understanding from reading about memcpy-param-overlap is that we should use memmove when the memory addresses in the source and destination overlap. Here is the offending line we should change:

memcpy(dst_ptr, src_ptr, array_list->impl->data_size * copy_count);

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 a pull request may close this issue.

1 participant