Skip to content

Force rclcpp_lifecycle to be a shared lib#589

Open
spinningthelock wants to merge 1 commit into
mvukov:mainfrom
spinningthelock:fix_rclcpp_lifecycle_pluginlib
Open

Force rclcpp_lifecycle to be a shared lib#589
spinningthelock wants to merge 1 commit into
mvukov:mainfrom
spinningthelock:fix_rclcpp_lifecycle_pluginlib

Conversation

@spinningthelock
Copy link
Copy Markdown
Contributor

@spinningthelock spinningthelock commented Jan 13, 2026

This PR forces rclcpp_lifecycle to link as a shared library.

rclcpp_lifecycle contains an global variable that is indirectly used by plugins and libraries. We want the plugin and libraries that uses the rclcpp_lifecycle to have the same global variable. Current statically linking behavior will result in plugin having its own global variable (its a .so) and library/node that loads the plugin having its own global variable. This fixes this issue by forcing rclcpp_lifecycle to link as a shared library. The Dynamic Linker ensures that only one instance of the library’s global data is mapped into the process memory. Now the both plugin and library/node will load rclcpp_lifecycle.so and will result in a single global variable. End result is that rclcpp_lifecycle node in the main binary can control the lifecycle of plugin and node itself.

This PR is needed as ROS2_Control package controls its loaded ros2_plugins lifecycle from the main node. Without this PR, ros2_control_node will crash on runtime as it expects loaded ros2 plugins lifecycle be present in the global variable. In addition, dynamic loading of rclcpp_lifecycle is the default cmake ros2 behavior.

@spinningthelock spinningthelock force-pushed the fix_rclcpp_lifecycle_pluginlib branch from ac3226d to 35f537d Compare January 13, 2026 22:54
@mvukov
Copy link
Copy Markdown
Owner

mvukov commented Jan 18, 2026

Any chance this can be solved with a patch?

@spinningthelock
Copy link
Copy Markdown
Contributor Author

spinningthelock commented Jan 18, 2026

@mvukov Its not going to be a trivial change. We have to revert back-ported fix ros2/rclcpp#2183 and then apply the original fix ros2/rclcpp#1756 assuming it will apply cleanly and work as intended.
Good news is that this PR is only applicable to Humble. Jazzy has the original fix, which does not contain a global variable.

rclcpp_lifecycle contains an global variable that is accessed by some
plugins and libraries. We want the plugin and libraries that uses the
rclcpp_lifecycle to have the same global variable rather than the plugin
which loads the .so and library that will staticly link.
@spinningthelock spinningthelock force-pushed the fix_rclcpp_lifecycle_pluginlib branch from c21edfe to 2a4363c Compare April 28, 2026 20:18
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 this pull request may close these issues.

2 participants