Skip to content

Keep logging plugin loaded during process exit - #150

Draft
Quchaosheng wants to merge 4 commits into
ros2:rollingfrom
Quchaosheng:fix/2567-keep-logging-loaded
Draft

Quchaosheng wants to merge 4 commits into
ros2:rollingfrom
Quchaosheng:fix/2567-keep-logging-loaded

Conversation

@Quchaosheng

@Quchaosheng Quchaosheng commented Oct 21, 2026 •

Copy link
Copy Markdown

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

rcl_logging_implementation registered an atexit handler that released the logging plugin. During process teardown, that dlclose() could unmap the DSO containing the handler while it was still returning, producing a SIGSEGV.

Keep the logging plugin handle in a function-local allocation that is intentionally never destroyed, and stop registering the unload handler at process exit. Explicit unload_logging_library() remains available for tests. The reload test shuts down the active implementation before explicit unload and then verifies a second initialization.

Validation

  • DCO: passed.
  • Rpr__rcl_logging__ubuntu_resolute_amd64: passed (compile and test).

Draft deliberately: this needs to land together with the matching rmw_implementation change, and that PR still has unrelated Fast DDS test failures to separate.

@jp-pino

jp-pino commented Nov 20, 2026

Copy link
Copy Markdown

This change also fixes a second exit crash, and that one doesn't need the rmw_implementation change. In a process that uses spdlog itself, rcl_logging_spdlog's flush thread and the logger it registers with spdlog live until libspdlog's static destructors run. Those run after the atexit() unload, so they run the plugin's code after it's gone. On Lyrical every such process dies with SIGSEGV after main() returns, with or without rclcpp::shutdown().

I opened #152 for that before I found this PR; it makes the same change. It adds test_exit_with_spdlog, death tests that reproduce the crash: without the change they fail 0/10 (signal 11), with it they pass 10/10. I'll close #152 in favour of this one. You're welcome to take the test from there, or I can open it as a follow-up PR once this is in.

@Quchaosheng

Copy link
Copy Markdown
Author

Thanks, that is a useful second case, and the death tests are the right shape. I would rather keep this PR to the lifecycle change and leave the spdlog-specific test in #152 for now; if the maintainers prefer one PR I will pull it in. Either way I will link #152 from here.

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