EventsCBGExecutor segfaults when a timer is removed while its callback is running
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with timer_manager.hpp, especially the running timer's done callback and TimerQueue::remove_timer(); then read the shutdown path in events_cbg_executor.cpp. Reproduce with the linked gist and run the regression cases described in the issue. Done means callbacks can finish after timer removal or shutdown without a segfault, and the full rolling test suite passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Generated by Generative AI
Root-cause analysis, reproducer and text drafting with help of Claude Code (claude-opus-5-5)
Operating System:
Ubuntu 24.04 x86_64; rolling checked in the ros:rolling container.
ROS version or commit hash:
Jazzy: rclcpp 28.1.22 (binary packages); origin/jazzy 53fa7aee has the same code. Rolling: rclcpp 33.1.0 (binary packages); origin/rolling afe12bfa has the same code.
RMW implementation (if applicable):
rmw_fastrtps_cpp (default). Originally seen with rmw_zenoh_cpp; the bug isn't RMW-related.
RMW Configuration (if applicable):
No response
Client library (if applicable):
rclcpp
'ros2 doctor --report' output
No response
Steps to reproduce issue
- Gist: https://gist.github.com/spurnvoj/bd80f243880fe569a155421f7297ea3d
- git clone into ws/src, colcon build, bash src/cbg_timer_removal_repro/run.sh 10
- Setup: one node with a 1 s timer callback in EventsCBGExecutor; the timer is removed while that callback runs. Three modes:
- remove_node: executor.remove_node(), no shutdown
- sigint: Ctrl-C during spin()
- sigint_spin_some: Ctrl-C during a spin_some() loop
Expected behavior
The callback finishes, the removed timer isn't re-armed, and the process exits normally.
Actual behavior
SIGSEGV right after the callback returns, in all 3 modes, every run: Jazzy 10/10, rolling 5/5.
#0 rcl_timer_get_next_call_time () from /opt/ros/jazzy/lib/librcl.so
#1 ?? () from /opt/ros/jazzy/lib/librclcpp.so
#2 std::_Function_handler<void (), rclcpp::executors::cbg_executor::TimerQueue::get_ready_timer_callbacks()::{lambda()#1}>::_M_invoke(...) from /opt/ros/jazzy/lib/librclcpp.so
#3 ... ReadyEntity::get_execute_function() ... from /opt/ros/jazzy/lib/librclcpp.so
#4 rclcpp::executors::EventsCBGExecutor::run(unsigned long, bool) () from /opt/ros/jazzy/lib/librclcpp.so
Additional information
- Cause, timer_manager.hpp (jazzy 53fa7aee):
- the done callback of a running timer keeps a raw
TimerData *andthis(l. 388-396); TimerQueue::remove_timer()erases theunique_ptr<TimerData>(l. 218). That happens on node removal and inEventsCBGExecutor::shutdown(), which also destroys the wholetimer_manager(events_cbg_executor.cppl. 142, 159);- when the callback returns,
add_timer_to_running_map()uses the freed data; - the comment at l. 391-394 says the data stays valid; that holds only against
remove_if_dropped(), not againstremove_timer().
- the done callback of a running timer keeps a raw
- Ctrl-C path: the shutdown guard condition's handler runs synchronously on the thread calling
rclcpp::shutdown()(the signal handler thread). So shutdown frees state while worker threads are still running callbacks. Thetimer_manager.reset()comment, "no thread is working on it any more", doesn't hold. - Also reachable without shutdown: unloading a component (
ComponentManager→remove_node) while one of its timers runs. - Real-world impact:
component_container_events_cbgsegfaults on Ctrl-C when a timer callback is in flight. Found in the MRS UAV system (multi-component containers). - Related but different bugs: #3312 / #3313 (queued events of removed nodes outlive the unloaded library), #3186 (double removal on shutdown).
- Fix ready: https://github.com/fly4future/rclcpp/tree/fix/events-cbg-timer-removal (PR to follow):
- internal to the source files only, no ABI change, backportable to Jazzy;
- regression test with 3 cases: unfixed rolling 10/10 segfault per case, fixed 10/10 pass;
- full rolling test suite passes.
- Ngôn ngữ chính
- C++
- Star
- 815
- Fork
- 572
- Merge trung bình
- 5 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ros2/rclcpp
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
EventsCBGExecutor timers on ROS time stall after a backward /clock jumpCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
Maintainer thường phản hồi trong vòng 1 ngày
-
:farmer: Flaky EventsCBGExecutor test: reentrant callback group fails to run callbacks concurrentlyĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Copy constructor exception leaks intra-process message allocationCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug core p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
FriendsofECCE/ECCE#336 · 1 bình luận ·
-
Real literal with a 'd' exponent and a kind suffix (1.0d0_4) is accepted; the suffix is ignoredĐang mởerror not reported low priority semantics
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
bitcoin-core/gui-qml#1030 ·
Maintainer thường phản hồi trong vòng 3 ngày