rmw icon indicating copy to clipboard operation
rmw copied to clipboard

rmw_get_zero_initialized_names_and_types has data race in multi thread environment

Open comicfans opened this issue 1 year ago • 0 comments

Bug report

Required Info:

  • Operating System: ubuntu 22.04
  • Installation type: source
  • Version or commit hash: 6.1.1
  • DDS implementation: don't know
  • Client library (if applicable): rclcpp

Steps to reproduce issue

Thread Sanitizer report https://github.com/ros2/rmw/blob/ac4f9afccca3dc305f2b519fdb0fb9131250f2a5/rmw/src/names_and_types.c#L31

rmw_names_and_types_t
rmw_get_zero_initialized_names_and_types(void)
{
  static rmw_names_and_types_t zero = {
    .names = {0, NULL, {NULL, NULL, NULL, NULL, NULL}},
    .types = NULL,
  };
  zero.names = rcutils_get_zero_initialized_string_array();
  return zero;
}

zero.names already inited, but later being re-assigned during runtime,while accessing from different thread, this is a data race. similar problem here https://github.com/ros2/rcutils/pull/478

Expected behavior

Actual behavior

Additional information


Feature request

Feature description

Implementation considerations

comicfans avatar Sep 08 '24 07:09 comicfans