Skip to content

Keep RMW plugin loaded during process exit - #305

Closed
Quchaosheng wants to merge 2 commits into
ros2:rollingfrom
Quchaosheng:fix/2567-keep-plugins-loaded
Closed

Quchaosheng wants to merge 2 commits into
ros2:rollingfrom
Quchaosheng:fix/2567-keep-plugins-loaded

Conversation

@Quchaosheng

Copy link
Copy Markdown

This is the RMW half of the exit-time dlclose() crash tracked by ros2/rclcpp#2567 and #301.

g_rmw_lib is a static shared_ptr. Its destructor can run during process exit after an application has dlclose()d the library that created the ROS 2 nodes. Releasing the RMW plugin can then unload librmw_implementation.so while the destructor itself is still executing, producing a SIGSEGV on return.

Keep the plugin handle in a function-local allocation that is intentionally never destroyed. unload_library() still resets it for tests and benchmarks, so explicit unload/reload behavior remains available.

This must be coordinated with the matching rcl_logging_implementation change; fixing only one side still leaves the other exit-time unload hazard.

Validation in the local reproduction:

  • Unpatched CycloneDDS dlopen_leak reproduction: 187 failures / 200.
  • The same reproduction remains flaky without both fixes, which is why this is being submitted together with the logging counterpart rather than as an isolated rclcpp change.

The test added here checks that an explicit unload is followed by lazy reload. It is not a substitute for a full source-matched Rolling build; this branch was not end-to-end tested against the installed Jazzy headers because the Jazzy rmw headers predate the Rolling source.

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.

1 participant