fix: resolve flaky test_resource_change_notifier and Humble demo node SIGSEGV#345
Open
fix: resolve flaky test_resource_change_notifier and Humble demo node SIGSEGV#345
Conversation
…n demo nodes Fix two flaky CI failures (#344): 1. test_resource_change_notifier: reorder declarations in all 16 tests so ResourceChangeNotifier is declared after shared state (promises, atomics). C++ destroys locals in reverse order, so the notifier's worker thread is now shut down before any captured variable is destroyed - preventing use-after-free when wait_for times out under CI load. 2. test_hybrid_suppression on Humble: fix demo node destructors to reset subscriptions and timers before implicit member destruction, and restructure main() to explicitly destroy the node before rclcpp::shutdown(). This reduces the SIGINT teardown race window that caused SIGSEGV (exit -11) on Humble. Closes #344
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes two CI flakes affecting ros2_medkit’s gateway unit tests (Rolling) and integration-test demo nodes (Humble), improving shutdown/teardown safety around background threads and ROS 2 node destruction.
Changes:
- Reorders local declarations in
test_resource_change_notifiersoResourceChangeNotifieris destroyed before callback-captured shared state, preventing use-after-free hangs on timeouts. - Hardens integration-test demo nodes’ shutdown by explicitly destroying the node before
rclcpp::shutdown()and resetting timers/subscriptions in destructors to reduce teardown races/SIGSEGVs on Humble.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ros2_medkit_integration_tests/demo_nodes/rpm_sensor.cpp | Reset timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/param_beacon_node.cpp | Ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/light_controller.cpp | Reset subscription/timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/lidar_sensor.cpp | Reset timers in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/engine_temp_sensor.cpp | Reset timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/door_status_sensor.cpp | Reset timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/calibration_service.cpp | Ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/brake_pressure_sensor.cpp | Reset timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/brake_actuator.cpp | Reset subscription/timer in destructor; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_integration_tests/demo_nodes/beacon_publisher.cpp | Add destructor to cancel/reset timer; ensure node is destroyed before rclcpp::shutdown(). |
| src/ros2_medkit_gateway/test/test_resource_change_notifier.cpp | Reorder declarations across tests so notifier teardown joins worker thread before shared state is destroyed. |
Avoid relying on transitive includes which can break across standard library or dependency changes.
mfaferek93
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
Fix two flaky CI failures on
main:test_resource_change_notifier timeout (Rolling): Reorder variable declarations in all 16 tests so
ResourceChangeNotifieris declared after shared state (promises, atomics). C++ destroys locals in reverse declaration order, so the notifier's worker thread is now shut down before any captured variable is destroyed - preventing use-after-free whenwait_fortimes out under CI load.test_hybrid_suppression SIGSEGV on Humble: Fix demo node destructors to reset subscriptions and timers before implicit member destruction, and restructure
main()to explicitly destroy the node beforerclcpp::shutdown(). This reduces the SIGINT teardown race window that caused SIGSEGV (exit -11) on Humble.Issue
Type
Testing
test_resource_change_notifierspecifically passes (16/16 tests)Checklist