Skip to content

Fix data race in IntraProcessManager::lowest_available_capacity - #3361

Merged
ahcorde merged 2 commits into
rollingfrom
ahcorde/rolling/fix_ipm_lowest_available_capacity_lock
Oct 20, 2026
Merged

ahcorde merged 2 commits into
rollingfrom
ahcorde/rolling/fix_ipm_lowest_available_capacity_lock

Conversation

@ahcorde

@ahcorde ahcorde commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

IntraProcessManager::lowest_available_capacity() reads pub_to_subs_ and subscriptions_ without taking mutex_, while adding or removing subscriptions modifies them under a unique_lock. Calling Publisher::lowest_available_ipm_capacity() while intra-process subscriptions are created or destroyed on another thread can read freed memory.

  • Take a shared_lock, like the other readers.
  • Add a test that queries the capacity while subscriptions are created and destroyed. Under ASan the old code fails with heap-use-after-free; the fixed code passes. >

Did you use Generative AI?

Claude Opus 5.5

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde ahcorde self-assigned this Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

ABI Compliance Check

❌ Verdict: incompatible

Library Verdict Summary
libcomponent_manager.so ✅ compatible No ABI changes detected.
librclcpp.so ❌ incompatible ABI changed: 0 removed, 1 changed, 0 added declaration(s); removed or changed declarations break backward compatibility.
librclcpp_action.so ✅ compatible No ABI changes detected.
librclcpp_lifecycle.so ✅ compatible No ABI changes detected.
✅ libcomponent_manager.so — full abidiff report

Compared:

  • Base: lib-base/libcomponent_manager.so
  • Head: lib-pr/libcomponent_manager.so @ 951bf9a
(empty report — no differences printed by abidiff)
❌ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ 951bf9a
Functions changes summary: 0 Removed (41 filtered out), 1 Changed (1722 filtered out), 0 Added (19 filtered out) functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'method rclcpp::node_interfaces::NodeParameters::NodeParameters(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr, rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr, rclcpp::node_interfaces::NodeServicesInterface::SharedPtr, rclcpp::node_interfaces::NodeClockInterface::SharedPtr, const std::vector<rclcpp::Parameter, std::allocator<rclcpp::Parameter> >&, bool, bool, const rclcpp::QoS&, const rclcpp::PublisherOptionsBase&, bool, bool)' at node_parameters.cpp:67:1 has some indirect sub-type changes:
    implicit parameter 0 of type 'rclcpp::node_interfaces::NodeParameters*' has sub-type changes:
      in pointed to type 'class rclcpp::node_interfaces::NodeParameters' at node_parameters.hpp:83:1:
        type size changed from 2496 to 2624 (in bits)
        no member function changes (24 filtered);
        1 data member insertion:
          'rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_', at offset 2368 (in bits) at node_parameters.hpp:260:1
        1 data member changes (1 filtered):
          'rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_' offset changed from 2368 to 2496 (in bits) (by +128 bits)


✅ librclcpp_action.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_action.so
  • Head: lib-pr/librclcpp_action.so @ 951bf9a
(empty report — no differences printed by abidiff)
✅ librclcpp_lifecycle.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_lifecycle.so
  • Head: lib-pr/librclcpp_lifecycle.so @ 951bf9a
(empty report — no differences printed by abidiff)

Updated for commit 951bf9a · check run · suppressions: /home/runner/work/_temp/ros2-abi-suppressions.txt

Comment thread rclcpp/src/rclcpp/intra_process_manager.cpp Outdated
Co-authored-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde

ahcorde commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Pulls: #3361
Gist: https://gist.githubusercontent.com/ahcorde/9ef66eb81cbf0c56bc2d6932c88edb62/raw/acfeef116bb66b949e7eb9e6b7584658e390b3a8/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20823

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde
ahcorde merged commit 404d268 into rolling Oct 20, 2026
10 of 11 checks passed
@ahcorde
ahcorde deleted the ahcorde/rolling/fix_ipm_lowest_available_capacity_lock branch October 20, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants