Skip to content

Remove deprecated conversion of C++ allocators to rcl allocators - #3445

Draft
christophebedard wants to merge 1 commit into
rollingfrom
christophebedard/remove-deprecated-allocator-conversion
Draft

christophebedard wants to merge 1 commit into
rollingfrom
christophebedard/remove-deprecated-allocator-conversion

Conversation

@christophebedard

Copy link
Copy Markdown
Member

Description

Converting a C++ allocator to an rcl allocator with the generic allocator::get_rcl_allocator() and the retyped_*() functions has been deprecated since #3058 (Lyrical), since it is not valid: the size on deallocate cannot be determined. Allocators other than std::allocator<void> now need to define rcl_allocator_t get_rcl_allocator(), which is enforced with a static_assert.

Is this user-facing behavior change?

Yes: rclcpp::allocator::retyped_allocate(), retyped_zero_allocate(), retyped_deallocate(), retyped_reallocate(), and the generic rclcpp::allocator::get_rcl_allocator() overload are removed. Allocators other than std::allocator<void> used with publishers, subscriptions, or message memory strategies must define rcl_allocator_t get_rcl_allocator(), otherwise compilation fails.

Did you use Generative AI?

Claude Opus 5.5 to find this deprecated code and remove it.

Additional Information

Requires ros2/demos#823, which defines get_rcl_allocator() for the custom allocator tutorial, so merge that one first.

@github-actions

github-actions Bot commented Nov 27, 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, 2 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 @ 9890b5b
(empty report — no differences printed by abidiff)
❌ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ 9890b5b
Functions changes summary: 0 Removed, 2 Changed (103 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

2 functions with some indirect sub-type change:

  [C] 'method void rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::Publisher(rclcpp::node_interfaces::NodeBaseInterface*, const std::string&, const rclcpp::QoS&, const rclcpp::PublisherOptionsWithAllocator<std::allocator<void>>&)' at publisher.hpp:116:1 has some indirect sub-type changes:
    Please note that the symbol of this function is _ZN6rclcpp9PublisherIN14rcl_interfaces3msg15ParameterEvent_ISaIvEEES4_EC2EPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3QoSERKNS_29PublisherOptionsWithAllocatorIS4_EE
     and it aliases symbol: _ZN6rclcpp9PublisherIN14rcl_interfaces3msg15ParameterEvent_ISaIvEEES4_EC1EPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3QoSERKNS_29PublisherOptionsWithAllocatorIS4_EE
    implicit parameter 0 of type 'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>*' has sub-type changes:
      in pointed to type 'class rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>' at publisher.hpp:78:1:
        type size changed from 5952 to 5824 (in bits)
        no member function changes (4 filtered);
        6 data member changes:
          type of 'const rclcpp::PublisherOptionsWithAllocator<std::allocator<void>> options_' changed:
            in unqualified underlying type 'struct rclcpp::PublisherOptionsWithAllocator<std::allocator<void>>' at publisher_options.hpp:70:1:
              type size changed from 2752 to 2624 (in bits)
              1 data member deletion:
                'std::shared_ptr<std::allocator<char>> plain_allocator_storage_', at offset 2624 (in bits) at publisher_options.hpp:148:1
          'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::PublishedTypeAllocator published_type_allocator_' offset changed from 5760 to 5632 (in bits) (by -128 bits)
          'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::PublishedTypeDeleter published_type_deleter_' offset changed from 5768 to 5640 (in bits) (by -128 bits)
          'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::ROSMessageTypeAllocator ros_message_type_allocator_' offset changed from 5776 to 5648 (in bits) (by -128 bits)
          'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::ROSMessageTypeDeleter ros_message_type_deleter_' offset changed from 5784 to 5656 (in bits) (by -128 bits)
          'rclcpp::Publisher<rcl_interfaces::msg::ParameterEvent_<std::allocator<void>>,std::allocator<void>>::BufferSharedPtr buffer_' offset changed from 5824 to 5696 (in bits) (by -128 bits)

  [C] 'method void rclcpp::Subscription<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rclcpp::message_memory_strategy::MessageMemoryStrategy<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>>::Subscription(rclcpp::node_interfaces::NodeBaseInterface*, const rosidl_message_type_support_t&, const std::string&, const rclcpp::QoS&, rclcpp::AnySubscriptionCallback<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>, const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>>&, rclcpp::message_memory_strategy::MessageMemoryStrategy<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>::SharedPtr)' at subscription.hpp:109:1 has some indirect sub-type changes:
    Please note that the symbol of this function is _ZN6rclcpp12SubscriptionIN13rosgraph_msgs3msg6Clock_ISaIvEEES4_S5_S5_NS_23message_memory_strategy21MessageMemoryStrategyIS5_S4_EEEC2EPNS_15node_interfaces17NodeBaseInterfaceERK29rosidl_message_type_support_tRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3QoSENS_23AnySubscriptionCallbackIS5_S4_EERKNS_32SubscriptionOptionsWithAllocatorIS4_EESt10shared_ptrIS8_E
     and it aliases symbol: _ZN6rclcpp12SubscriptionIN13rosgraph_msgs3msg6Clock_ISaIvEEES4_S5_S5_NS_23message_memory_strategy21MessageMemoryStrategyIS5_S4_EEEC1EPNS_15node_interfaces17NodeBaseInterfaceERK29rosidl_message_type_support_tRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3QoSENS_23AnySubscriptionCallbackIS5_S4_EERKNS_32SubscriptionOptionsWithAllocatorIS4_EESt10shared_ptrIS8_E
    implicit parameter 0 of type 'rclcpp::Subscription<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rclcpp::message_memory_strategy::MessageMemoryStrategy<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>>*' has sub-type changes:
      in pointed to type 'class rclcpp::Subscription<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rosgraph_msgs::msg::Clock_<std::allocator<void>>,rclcpp::message_memory_strategy::MessageMemoryStrategy<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>>' at subscription.hpp:70:1:
        type size changed from 9280 to 9152 (in bits)
        no member function changes (15 filtered);
        2 data member changes:
          type of 'const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> options_' changed:
            in unqualified underlying type 'struct rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>>' at subscription_options.hpp:81:1:
              type size changed from 3712 to 3584 (in bits)
              1 data member deletion:
                'std::shared_ptr<std::allocator<char>> plain_allocator_storage_', at offset 3584 (in bits) at subscription_options.hpp:187:1
          'rclcpp::message_memory_strategy::MessageMemoryStrategy<rosgraph_msgs::msg::Clock_<std::allocator<void>>,std::allocator<void>>::SharedPtr message_memory_strategy_' offset changed from 9152 to 9024 (in bits) (by -128 bits)


✅ librclcpp_action.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_action.so
  • Head: lib-pr/librclcpp_action.so @ 9890b5b
(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 @ 9890b5b
(empty report — no differences printed by abidiff)

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

rclcpp::allocator::has_get_rcl_allocator_v<Allocator>,
"Allocators other than std::allocator<void> must define "
"'rcl_allocator_t get_rcl_allocator()'");
return get_allocator()->get_rcl_allocator();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unreachable, is it needed ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not unreachable. It's kind of backwards: the static_assert() isn't actually needed, because get_allocator()->get_rcl_allocator() wouldn't compile anyway, but it gives a nicer compile error.

@christophebedard

Copy link
Copy Markdown
Member Author

Pulls: #3445
Gist: https://gist.githubusercontent.com/christophebedard/f717dfd10b5d2f8d4c5d6ebfc45d4135/raw/032df4e72030ac7f6965be0b73fa203d67175fb6/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/21360

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

@christophebedard

Copy link
Copy Markdown
Member Author

so it seems that the deprecations this PR removes weren't actually getting shown to users, similar to #3176.

Even if this probably doesn't have many users, I'll hold off on this one for now.

@christophebedard
christophebedard marked this pull request as draft November 27, 2026 19:11
Base automatically changed from christophebedard/remove-memory-strategy to rolling November 28, 2026 00:15
Converting a C++ allocator to an rcl allocator with the generic
`allocator::get_rcl_allocator()` and the `retyped_*()` functions has
been deprecated since #3058
(Lyrical), since it is not valid: the size on deallocate cannot be
determined. Allocators other than `std::allocator<void>` now need to
define `rcl_allocator_t get_rcl_allocator()`, which is enforced with a
`static_assert`.

Signed-off-by: Christophe Bedard <[email protected]>
@christophebedard
christophebedard force-pushed the christophebedard/remove-deprecated-allocator-conversion branch from fff1e8f to 9890b5b Compare November 28, 2026 00:15
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.

3 participants