Skip to content

EventsExecutor segmentation faults due to pub/sub destruction with event_callbacks #1644

Description

@campbell-remedy

Generated by Generative AI

No but gemini-3.1-pro/gemini-3-flash helped make the repro script

Operating System:

Linux Naboo 6.17.0-20-generic #20~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 01:28:37 UTC 2 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 24.04.4 LTS)

ROS version or commit hash:

jazzy

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclpy

'ros2 doctor --report' output

ros2 doctor --report
   NETWORK CONFIGURATION
inet         : 127.0.0.1
inet4        : ['127.0.0.1']
inet6        : ['::1']
netmask      : 255.0.0.0
device       : lo
flags        : 73<LOOPBACK,UP,RUNNING>
mtu          : 65536
inet         : 192.168.1.128
inet4        : ['192.168.1.128']
ether        : 1c:fd:08:78:91:f9
inet6        : ['2600:1700:479:c01f:f099:d65e:6594:cb9', '2600:1700:479:c01f:17e8:85ac:1ef2:2f89', '2600:1700:479:c01f:d3f7:2d13:bbf9:f39d', 'fe80::d913:f7f0:f0a8:62ac%enp16s0f1']
netmask      : 255.255.255.0
device       : enp16s0f1
flags        : 4163<BROADCAST,UP,RUNNING,MULTICAST>
mtu          : 1500
broadcast    : 192.168.1.255
inet         : 172.17.0.1
inet4        : ['172.17.0.1']
ether        : f6:b2:8d:fc:81:94
netmask      : 255.255.0.0
device       : docker0
flags        : 4099<BROADCAST,UP,MULTICAST>
mtu          : 1500
broadcast    : 172.17.255.255
ether        : 74:56:3c:4b:7c:75
device       : enp19s0
flags        : 4099<BROADCAST,UP,MULTICAST>
mtu          : 1500
ether        : 1c:fd:08:78:91:fa
device       : enp17s0f0
flags        : 4099<BROADCAST,UP,MULTICAST>
mtu          : 1500
ether        : 1c:fd:08:78:91:fb
device       : enp17s0f1
flags        : 4099<BROADCAST,UP,MULTICAST>
mtu          : 1500
ether        : f4:c8:8a:cf:21:69
device       : wlp21s0
flags        : 4098<BROADCAST,MULTICAST>
mtu          : 1500

   PACKAGE VERSIONS
...internal packages...
lttngpy                                   : latest=8.2.5, local=8.2.5
tf2_eigen_kdl                             : latest=0.36.20, local=0.36.19
examples_rclcpp_minimal_composition       : latest=0.19.7, local=0.19.7
nav_msgs                                  : latest=5.3.7, local=5.3.6
rmw_fastrtps_cpp                          : latest=8.4.3, local=8.4.3
rqt_graph                                 : latest=1.5.6, local=1.5.6
rqt_plot                                  : latest=1.4.5, local=1.4.5
tf2_sensor_msgs                           : latest=0.36.20, local=0.36.19
theora_image_transport                    : latest=4.0.6, local=4.0.6
rqt_runtime_monitor                       : latest=1.0.0, local=1.0.0
launch_pytest                             : latest=3.4.10, local=3.4.10
rviz_default_plugins                      : latest=14.1.20, local=14.1.19
type_description_interfaces               : latest=2.0.3, local=2.0.3
rqt_robot_steering                        : latest=2.0.0, local=2.0.0
ament_cmake_libraries                     : latest=2.5.6, local=2.5.5
rqt_gauges                                : latest=0.0.3, local=0.0.3
qt_gui                                    : latest=2.7.6, local=2.7.5
examples_rclcpp_minimal_client            : latest=0.19.7, local=0.19.7
rmw                                       : latest=7.3.3, local=7.3.3
sdformat_vendor                           : latest=0.0.11, local=0.0.10
image_transport                           : latest=5.1.7, local=5.1.7
ros2cli_common_extensions                 : latest=0.3.1, local=0.3.1
joy                                       : latest=3.3.0, local=3.3.0
ament_cmake_pytest                        : latest=2.5.6, local=2.5.5
ament_pep257                              : latest=0.17.4, local=0.17.4
rclcpp                                    : latest=28.1.18, local=28.1.16
pendulum_control                          : latest=0.33.10, local=0.33.9
ros2launch                                : latest=0.26.11, local=0.26.11
pcl_msgs                                  : latest=1.0.0, local=1.0.0
examples_rclpy_minimal_service            : latest=0.19.7, local=0.19.7
rmw_fastrtps_shared_cpp                   : latest=8.4.3, local=8.4.3
geometry_msgs                             : latest=5.3.7, local=5.3.6
examples_rclpy_minimal_action_server      : latest=0.19.7, local=0.19.7
stereo_msgs                               : latest=5.3.7, local=5.3.6
tf2_bullet                                : latest=0.36.20, local=0.36.19
domain_coordinator                        : latest=0.12.0, local=0.12.0
ros2run                                   : latest=0.32.9, local=0.32.8
image_tools                               : latest=0.33.10, local=0.33.9
rosbag2_transport                         : latest=0.26.10, local=0.26.9
keyboard_handler                          : latest=0.3.2, local=0.3.2
ament_cmake_auto                          : latest=2.5.6, local=2.5.5
rosidl_cli                                : latest=4.6.7, local=4.6.7
ament_cmake_export_dependencies           : latest=2.5.6, local=2.5.5
rosidl_typesupport_c                      : latest=3.2.2, local=3.2.2
examples_rclcpp_minimal_action_client     : latest=0.19.7, local=0.19.7
examples_rclcpp_minimal_action_server     : latest=0.19.7, local=0.19.7
pluginlib                                 : latest=5.4.5, local=5.4.4
ros2doctor                                : latest=0.32.9, local=0.32.8
rcl_action                                : latest=9.2.9, local=9.2.9
rosidl_runtime_cpp                        : latest=4.6.7, local=4.6.7
ros_base                                  : latest=0.11.0, local=0.11.0
pybind11_vendor                           : latest=3.1.3, local=3.1.3
ament_lint_auto                           : latest=0.17.4, local=0.17.4
rosbag2_py                                : latest=0.26.10, local=0.26.9
ament_cmake_cppcheck                      : latest=0.17.4, local=0.17.4
ament_cmake_export_libraries              : latest=2.5.6, local=2.5.5
sros2_cmake                               : latest=0.13.6, local=0.13.5
rcl_lifecycle                             : latest=9.2.9, local=9.2.9
tcb_span                                  : latest=1.2.0, local=1.2.0
ament_cmake_ros                           : latest=0.12.0, local=0.12.0
rosidl_runtime_c                          : latest=4.6.7, local=4.6.7
kdl_parser                                : latest=2.11.0, local=2.11.0
ros2cli                                   : latest=0.32.9, local=0.32.8
rosbridge_msgs                            : latest=2.6.0, local=2.4.2
rosidl_core_generators                    : latest=0.2.1, local=0.2.0
urdf_parser_plugin                        : latest=2.10.0, local=2.10.0
gz_cmake_vendor                           : latest=0.0.11, local=0.0.10
smclib                                    : latest=4.2.0, local=4.1.2
rosbag2_interfaces                        : latest=0.26.10, local=0.26.9
python_qt_binding                         : latest=2.2.2, local=2.2.2
action_tutorials_interfaces               : latest=0.33.10, local=0.33.9
depthimage_to_laserscan                   : latest=2.5.1, local=2.5.1
ament_cmake_clang_format                  : latest=0.17.4, local=0.17.4
gz_math_vendor                            : latest=0.0.8, local=0.0.8
ament_copyright                           : latest=0.17.4, local=0.17.4
rqt_dotgraph                              : latest=0.0.5, local=0.0.5
rviz2                                     : latest=14.1.20, local=14.1.19
geometry2                                 : latest=0.36.20, local=0.36.19
rclcpp_action                             : latest=28.1.18, local=28.1.16
ros2bag                                   : latest=0.26.10, local=0.26.9
ament_cmake_export_link_flags             : latest=2.5.6, local=2.5.5
rqt_reconfigure                           : latest=1.6.4, local=1.6.3
rcl_interfaces                            : latest=2.0.3, local=2.0.3
class_loader                              : latest=2.7.0, local=2.7.0
ros2lifecycle                             : latest=0.32.9, local=0.32.8
ros2param                                 : latest=0.32.9, local=0.32.8
ament_uncrustify                          : latest=0.17.4, local=0.17.4
rosbag2_cpp                               : latest=0.26.10, local=0.26.9
ros2node                                  : latest=0.32.9, local=0.32.8
logging_demo                              : latest=0.33.10, local=0.33.9
rosidl_typesupport_introspection_c        : latest=4.6.7, local=4.6.7
libstatistics_collector                   : latest=1.7.4, local=1.7.4
shape_msgs                                : latest=5.3.7, local=5.3.6
dummy_sensors                             : latest=0.33.10, local=0.33.9
uncrustify_vendor                         : latest=3.0.1, local=3.0.1
rmw_implementation_cmake                  : latest=7.3.3, local=7.3.3
rosidl_pycommon                           : latest=4.6.7, local=4.6.7
gz_tools_vendor                           : latest=0.0.7, local=0.0.7
rosidl_parser                             : latest=4.6.7, local=4.6.7
rclcpp_components                         : latest=28.1.18, local=28.1.16
cv_bridge                                 : latest=4.1.0, local=4.1.0
controller_interface                      : latest=4.44.0, local=4.42.2
lifecycle                                 : latest=0.33.10, local=0.33.9
composition                               : latest=0.33.10, local=0.33.9
rcl_yaml_param_parser                     : latest=9.2.9, local=9.2.9
std_srvs                                  : latest=5.3.7, local=5.3.6
rosbridge_library                         : latest=2.6.0, local=2.4.2
sdl2_vendor                               : latest=3.3.0, local=3.3.0
geographic_msgs                           : latest=1.0.6, local=1.0.6
ros2interface                             : latest=0.32.9, local=0.32.8
rosapi                                    : latest=2.6.0, local=2.4.2
sros2                                     : latest=0.13.6, local=0.13.5
actionlib_msgs                            : latest=5.3.7, local=5.3.6
zstd_vendor                               : latest=0.26.10, local=0.26.9
rosidl_core_runtime                       : latest=0.2.1, local=0.2.0
teleop_twist_joy                          : latest=2.6.5, local=2.6.5
rosidl_dynamic_typesupport                : latest=0.1.2, local=0.1.2
python_orocos_kdl_vendor                  : latest=0.5.1, local=0.5.1
ament_lint                                : latest=0.17.4, local=0.17.4
rosx_introspection                        : latest=2.3.0, local=1.0.2
rosidl_typesupport_introspection_cpp      : latest=4.6.7, local=4.6.7
examples_rclcpp_multithreaded_executor    : latest=0.19.7, local=0.19.7
example_interfaces                        : latest=0.12.0, local=0.12.0
urdf                                      : latest=2.10.0, local=2.10.0
bond                                      : latest=4.2.0, local=4.1.2
examples_rclpy_minimal_subscriber         : latest=0.19.7, local=0.19.7
rosbag2_storage_mcap                      : latest=0.26.10, local=0.26.9
joint_limits                              : latest=4.44.0, local=4.42.2
mcap_vendor                               : latest=0.26.10, local=0.26.9
rviz_assimp_vendor                        : latest=14.1.20, local=14.1.19
ament_package                             : latest=0.16.5, local=0.16.5
laser_geometry                            : latest=2.7.2, local=2.7.2
map_msgs                                  : latest=2.4.1, local=2.4.1
realtime_tools                            : latest=3.11.0, local=3.10.1
rosidl_default_runtime                    : latest=1.6.0, local=1.6.0
foxglove_bridge                           : latest=3.2.6, local=3.2.3
ros2component                             : latest=0.32.9, local=0.32.8
tracetools                                : latest=8.2.5, local=8.2.5
ament_cmake_export_targets                : latest=2.5.6, local=2.5.5
rqt_common_plugins                        : latest=1.2.0, local=1.2.0
rosidl_generator_py                       : latest=0.22.2, local=0.22.2
launch_testing_ament_cmake                : latest=3.4.10, local=3.4.10
rqt_robot_monitor                         : latest=1.0.6, local=1.0.6
rosbag2_compression                       : latest=0.26.10, local=0.26.9
ament_cppcheck                            : latest=0.17.4, local=0.17.4
rosapi_msgs                               : latest=2.6.0, local=2.4.2
ament_cmake_gmock                         : latest=2.5.6, local=2.5.5
point_cloud_transport                     : latest=4.0.7, local=4.0.7
ament_cmake_flake8                        : latest=0.17.4, local=0.17.4
ament_cmake_lint_cmake                    : latest=0.17.4, local=0.17.4
action_tutorials_py                       : latest=0.33.10, local=0.33.9
sensor_msgs                               : latest=5.3.7, local=5.3.6
ament_index_cpp                           : latest=1.8.3, local=1.8.2
rqt_action                                : latest=2.2.1, local=2.2.1
rosbag2                                   : latest=0.26.10, local=0.26.9
tf2_py                                    : latest=0.36.20, local=0.36.19
dummy_robot_bringup                       : latest=0.33.10, local=0.33.9
rosidl_cmake                              : latest=4.6.7, local=4.6.7
service_msgs                              : latest=2.0.3, local=2.0.3
message_filters                           : latest=4.11.12, local=4.11.10
rttest                                    : latest=0.17.1, local=0.17.1
ament_cpplint                             : latest=0.17.4, local=0.17.4
tracetools_trace                          : latest=8.2.5, local=8.2.5
quality_of_service_demo_py                : latest=0.33.10, local=0.33.9
ament_cmake_gen_version_h                 : latest=2.5.6, local=2.5.5
tf2_geometry_msgs                         : latest=0.36.20, local=0.36.19
tf2_kdl                                   : latest=0.36.20, local=0.36.19
qt_gui_py_common                          : latest=2.7.6, local=2.7.5
yaml_cpp_vendor                           : latest=9.0.1, local=9.0.1
rosidl_typesupport_cpp                    : latest=3.2.2, local=3.2.2
hardware_interface                        : latest=4.44.0, local=4.42.2
fastrtps_cmake_module                     : latest=3.6.3, local=3.6.3
intra_process_demo                        : latest=0.33.10, local=0.33.9
desktop                                   : latest=0.11.0, local=0.11.0
camera_calibration_parsers                : latest=5.1.7, local=5.1.7
composition_interfaces                    : latest=2.0.3, local=2.0.3
launch_yaml                               : latest=3.4.10, local=3.4.10
ament_cmake_export_include_directories    : latest=2.5.6, local=2.5.5
robot_state_publisher                     : latest=3.3.3, local=3.3.3
sdformat_urdf                             : latest=1.0.2, local=1.0.2
rosbag2_storage                           : latest=0.26.10, local=0.26.9
tf2_eigen                                 : latest=0.36.20, local=0.36.19
rcl_logging_spdlog                        : latest=3.1.1, local=3.1.1
orocos_kdl_vendor                         : latest=0.5.1, local=0.5.1
rqt_gui_cpp                               : latest=1.6.3, local=1.6.3
ros2plugin                                : latest=5.4.5, local=5.4.4
ros2service                               : latest=0.32.9, local=0.32.8
rmw_implementation                        : latest=2.15.6, local=2.15.6
image_geometry                            : latest=4.1.0, local=4.1.0
rqt_robot_dashboard                       : latest=0.6.1, local=0.6.1
diagnostic_updater                        : latest=4.2.6, local=4.2.6
tl_expected                               : latest=1.2.0, local=1.2.0
rosbag2_storage_sqlite3                   : latest=0.26.10, local=0.26.9
action_tutorials_cpp                      : latest=0.33.10, local=0.33.9
liblz4_vendor                             : latest=0.26.10, local=0.26.9
tf2                                       : latest=0.36.20, local=0.36.19
diagnostic_msgs                           : latest=5.3.7, local=5.3.6
ament_cmake_xmllint                       : latest=0.17.4, local=0.17.4
common_interfaces                         : latest=5.3.7, local=5.3.6
rclcpp_lifecycle                          : latest=28.1.18, local=28.1.16
rcl                                       : latest=9.2.9, local=9.2.9
ament_flake8                              : latest=0.17.4, local=0.17.4
launch_testing_ros                        : latest=0.26.11, local=0.26.11
tinyxml2_vendor                           : latest=0.9.2, local=0.9.2
rqt_moveit                                : latest=1.0.1, local=1.0.1
rqt_msg                                   : latest=1.5.2, local=1.5.2
bondcpp                                   : latest=4.2.0, local=4.1.2
ros2action                                : latest=0.32.9, local=0.32.8
rqt_controller_manager                    : latest=4.44.0, local=4.42.2
tf2_tools                                 : latest=0.36.20, local=0.36.19
rosidl_generator_cpp                      : latest=4.6.7, local=4.6.7
pcl_conversions                           : latest=2.6.4, local=2.6.2
rpyutils                                  : latest=0.4.2, local=0.4.2
ament_lint_common                         : latest=0.17.4, local=0.17.4
rqt_tf_tree                               : latest=1.0.6, local=1.0.5
pal_statistics                            : latest=2.7.0, local=2.7.0
topic_monitor                             : latest=0.33.10, local=0.33.9
ament_cmake_test                          : latest=2.5.6, local=2.5.5
rclpy                                     : latest=7.1.11, local=7.1.9
rmw_dds_common                            : latest=3.1.1, local=3.1.1
launch                                    : latest=3.4.10, local=3.4.10
examples_rclcpp_minimal_publisher         : latest=0.19.7, local=0.19.7
controller_manager_msgs                   : latest=4.44.0, local=4.42.2
sqlite3_vendor                            : latest=0.26.10, local=0.26.9
osrf_pycommon                             : latest=2.1.7, local=2.1.7
examples_rclpy_minimal_publisher          : latest=0.19.7, local=0.19.7
ros2trace                                 : latest=8.2.5, local=8.2.5
nav2_msgs                                 : latest=1.3.11, local=1.3.10
ament_cmake_target_dependencies           : latest=2.5.6, local=2.5.5
examples_rclpy_minimal_action_client      : latest=0.19.7, local=0.19.7
rosbag2_storage_default_plugins           : latest=0.26.10, local=0.26.9
action_msgs                               : latest=2.0.3, local=2.0.3
trajectory_msgs                           : latest=5.3.7, local=5.3.6
rqt_py_common                             : latest=1.6.3, local=1.6.3
rqt_publisher                             : latest=1.7.3, local=1.7.3
rqt_srv                                   : latest=1.2.3, local=1.2.3
rqt_service_caller                        : latest=1.2.2, local=1.2.2
ros_core                                  : latest=0.11.0, local=0.11.0
eigen3_cmake_module                       : latest=0.3.0, local=0.3.0
pendulum_msgs                             : latest=0.33.10, local=0.33.9
generate_parameter_library_py             : latest=0.7.1, local=0.6.0
rviz_ogre_vendor                          : latest=14.1.20, local=14.1.19
launch_testing                            : latest=3.4.10, local=3.4.10
ament_cmake_gtest                         : latest=2.5.6, local=2.5.5
ros_environment                           : latest=4.2.1, local=4.2.1
ament_cmake                               : latest=2.5.6, local=2.5.5
tf2_msgs                                  : latest=0.36.20, local=0.36.19
rosidl_typesupport_fastrtps_c             : latest=3.6.3, local=3.6.3
parameter_traits                          : latest=0.7.1, local=0.6.0
ament_xmllint                             : latest=0.17.4, local=0.17.4
rosidl_adapter                            : latest=4.6.7, local=4.6.7
ament_cmake_pep257                        : latest=0.17.4, local=0.17.4
teleop_twist_keyboard                     : latest=2.4.1, local=2.4.1
statistics_msgs                           : latest=2.0.3, local=2.0.3
rqt_joint_trajectory_controller           : latest=4.39.0, local=4.36.0
std_msgs                                  : latest=5.3.7, local=5.3.6
rcpputils                                 : latest=2.11.3, local=2.11.3
rqt_gui                                   : latest=1.6.3, local=1.6.3
rqt_gui_py                                : latest=1.6.3, local=1.6.3
interactive_markers                       : latest=2.5.5, local=2.5.5
nav2_util                                 : latest=1.3.11, local=1.3.10
unique_identifier_msgs                    : latest=2.5.0, local=2.5.0
angles                                    : latest=1.16.1, local=1.16.1
examples_rclcpp_minimal_subscriber        : latest=0.19.7, local=0.19.7
rqt_image_overlay                         : latest=0.4.0, local=0.4.0
rosgraph_msgs                             : latest=2.0.3, local=2.0.3
rcutils                                   : latest=6.7.5, local=6.7.5
examples_rclpy_executors                  : latest=0.19.7, local=0.19.7
rqt_image_view                            : latest=1.3.0, local=1.3.0
tlsf_cpp                                  : latest=0.17.1, local=0.17.1
examples_rclcpp_minimal_timer             : latest=0.19.7, local=0.19.7
rosidl_generator_type_description         : latest=4.6.7, local=4.6.7
pal_statistics_msgs                       : latest=2.7.0, local=2.7.0
ament_cmake_export_interfaces             : latest=2.5.6, local=2.5.5
rosidl_generator_c                        : latest=4.6.7, local=4.6.7
rqt_shell                                 : latest=1.2.3, local=1.2.3
rosbag2_compression_zstd                  : latest=0.26.10, local=0.26.9
demo_nodes_py                             : latest=0.33.10, local=0.33.9
console_bridge_vendor                     : latest=1.7.1, local=1.7.1
launch_xml                                : latest=3.4.10, local=3.4.10
qt_dotgraph                               : latest=2.7.6, local=2.7.5
ros2topic                                 : latest=0.32.9, local=0.32.8
rqt_bag_plugins                           : latest=1.5.6, local=1.5.6
ros_workspace                             : latest=1.0.3, local=1.0.3
rosidl_typesupport_interface              : latest=4.6.7, local=4.6.7
ament_index_python                        : latest=1.8.3, local=1.8.2
image_view                                : latest=5.0.11, local=5.0.11
qt_gui_cpp                                : latest=2.7.6, local=2.7.5
rclpy_message_converter                   : latest=2.0.1, local=2.0.1
generate_parameter_library                : latest=0.7.1, local=0.6.0
gz_utils_vendor                           : latest=0.0.5, local=0.0.5
tlsf                                      : latest=0.9.0, local=0.9.0
ament_lint_cmake                          : latest=0.17.4, local=0.17.4
builtin_interfaces                        : latest=2.0.3, local=2.0.3
tf2_ros                                   : latest=0.36.20, local=0.36.19
demo_nodes_cpp_native                     : latest=0.33.10, local=0.33.9
demo_nodes_cpp                            : latest=0.33.10, local=0.33.9
turtlesim                                 : latest=1.8.3, local=1.8.3
nav2_common                               : latest=1.3.11, local=1.3.10
ament_cmake_cpplint                       : latest=0.17.4, local=0.17.4
ament_cmake_python                        : latest=2.5.6, local=2.5.5
ament_cmake_version                       : latest=2.5.6, local=2.5.5
controller_manager                        : latest=4.44.0, local=4.42.2
ros2multicast                             : latest=0.32.9, local=0.32.8
ament_cmake_core                          : latest=2.5.6, local=2.5.5
rosidl_default_generators                 : latest=1.6.0, local=1.6.0
rqt_bag                                   : latest=1.5.6, local=1.5.6
rcl_logging_interface                     : latest=3.1.1, local=3.1.1
lifecycle_msgs                            : latest=2.0.3, local=2.0.3
examples_rclcpp_minimal_service           : latest=0.19.7, local=0.19.7
sensor_msgs_py                            : latest=5.3.7, local=5.3.6
python_cmake_module                       : latest=0.11.1, local=0.11.1
spdlog_vendor                             : latest=1.6.1, local=1.6.1
rosidl_typesupport_fastrtps_cpp           : latest=3.6.3, local=3.6.3
rqt_image_overlay_layer                   : latest=0.4.0, local=0.4.0
rosidl_dynamic_typesupport_fastrtps       : latest=0.1.0, local=0.1.0
examples_rclpy_minimal_client             : latest=0.19.7, local=0.19.7
ament_clang_format                        : latest=0.17.4, local=0.17.4
rviz_common                               : latest=14.1.20, local=14.1.19
ament_cmake_uncrustify                    : latest=0.17.4, local=0.17.4
rosidl_runtime_py                         : latest=0.13.1, local=0.13.1
rqt_console                               : latest=2.2.2, local=2.2.2
ament_cmake_include_directories           : latest=2.5.6, local=2.5.5
rqt_py_console                            : latest=1.2.3, local=1.2.3
tango_icons_vendor                        : latest=0.3.1, local=0.3.1
quality_of_service_demo_cpp               : latest=0.33.10, local=0.33.9
visualization_msgs                        : latest=5.3.7, local=5.3.6
libcurl_vendor                            : latest=3.4.4, local=3.4.4
rviz_rendering                            : latest=14.1.20, local=14.1.19
rqt_topic                                 : latest=1.7.5, local=1.7.5
ament_cmake_export_definitions            : latest=2.5.6, local=2.5.5
ros2pkg                                   : latest=0.32.9, local=0.32.8
ros_image_to_qimage                       : latest=0.4.1, local=0.4.1
resource_retriever                        : latest=3.4.4, local=3.4.4
control_msgs                              : latest=5.9.0, local=5.7.0
tf2_ros_py                                : latest=0.36.20, local=0.36.19
dummy_map_server                          : latest=0.33.10, local=0.33.9
rosbridge_server                          : latest=2.6.0, local=2.4.2
libyaml_vendor                            : latest=1.6.3, local=1.6.3
launch_ros                                : latest=0.26.11, local=0.26.11
ament_cmake_copyright                     : latest=0.17.4, local=0.17.4

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-6.17.0-19-generic-x86_64-with-glibc2.39
release          : 6.17.0-19-generic
processor        : x86_64

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : jazzy
distribution type      : ros2
distribution status    : active
release platforms      : {'debian': ['bookworm'], 'rhel': ['9'], 'ubuntu': ['noble']}

   TOPIC LIST
topic               : /topic_0
publisher count     : 0
subscriber count    : 0
topic               : /topic_1
publisher count     : 0
subscriber count    : 0
topic               : /topic_2
publisher count     : 0
subscriber count    : 0
topic               : /topic_3
publisher count     : 0
subscriber count    : 0
topic               : /topic_4
publisher count     : 0
subscriber count    : 0
topic               : /topic_5
publisher count     : 0
subscriber count    : 0
topic               : /topic_6
publisher count     : 0
subscriber count    : 0

Steps to reproduce issue

  1. Create a Node and add it to an EventsExecutor
  2. Create publisher(s) on a Node with event callbacks
  3. Create subscriber on external Node to cause the "matched" event to cause event callbacks to get enqueued
  4. Spin our primary node to start handling events
  5. Destroy the publisher(s)
  6. Spin again
  7. Segmentation Fault (seems to be a race-condition, and sometimes requires a few tries)
Example reproduction script
import multiprocessing
import time

import rclpy
from rclpy.event_handler import PublisherEventCallbacks
from rclpy.experimental.events_executor import EventsExecutor
from std_msgs.msg import String

num_topics = 10
num_tries = 50

def trigger_process():
  rclpy.init()
  node = rclpy.create_node("trigger_node")
  print("[Trigger] Generating Discovery Storm...")
  while rclpy.ok():
    subs = [
      node.create_subscription(
        String,
        f"topic_{i % num_topics}",
        lambda m: None,
        10,
      )
      for i in range(20)
    ]
    time.sleep(0.01)
    for s in subs:
      node.destroy_subscription(s)


def listener_process():
  rclpy.init()
  node = rclpy.create_node("repro_node")
  executor = EventsExecutor()
  executor.add_node(node)

  print("[Listener] Main thread spinning. Expect crash soon...")

  for i in range(num_tries):
    print(
      f"[Listener] Iteration {i}: Creating publishers with event callbacks..."
    )
    pubs = [
      node.create_publisher(
        String,
        f"topic_{j}",
        10,
        event_callbacks=PublisherEventCallbacks(matched=lambda e: None),
      )
      for j in range(num_topics)
    ]
    time.sleep(0.01)
    try:
      executor.spin_once(timeout_sec=0)
    except rclpy._rclpy_pybind11.InvalidHandle:
      print("[Listener] Caught InvalidHandle exception during spin_once.")
    for w in pubs:
      node.destroy_publisher(w)

  print("[Listener] Finished without crash.")


if __name__ == "__main__":
  p = multiprocessing.Process(target=trigger_process)
  p.start()

  try:
    listener_process()
  finally:
    p.kill()
    p.join()
Observed output on example runs
$ python repro_events_executor.py
[Listener] Main thread spinning. Expect crash soon...
[Listener] Iteration 0: Creating publishers with event callbacks...
[Trigger] Generating Discovery Storm...
[Listener] Iteration 1: Creating publishers with event callbacks...
[Listener] Iteration 2: Creating publishers with event callbacks...
[Listener] Iteration 3: Creating publishers with event callbacks...
[Listener] Iteration 4: Creating publishers with event callbacks...
[Listener] Iteration 5: Creating publishers with event callbacks...
[Listener] Iteration 6: Creating publishers with event callbacks...
[Listener] Iteration 7: Creating publishers with event callbacks...
[Listener] Iteration 8: Creating publishers with event callbacks...
[Listener] Iteration 9: Creating publishers with event callbacks...
[Listener] Iteration 10: Creating publishers with event callbacks...
[Listener] Iteration 11: Creating publishers with event callbacks...
[Listener] Iteration 12: Creating publishers with event callbacks...
[Listener] Iteration 13: Creating publishers with event callbacks...
[Listener] Iteration 14: Creating publishers with event callbacks...
[Listener] Iteration 15: Creating publishers with event callbacks...
Fatal Python error: Segmentation fault

Current thread 0x0000767d8f786740 (most recent call first):
  File "/home/campbell/rc/repro_events_executor.py", line 54 in listener_process
  File "/home/campbell/rc/repro_events_executor.py", line 68 in <module>

Extension modules: yaml._yaml, rcl_interfaces.rcl_interfaces_s__rosidl_typesupport_c, builtin_interfaces.builtin_interfaces_s__rosidl_typesupport_c, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, service_msgs.service_msgs_s__rosidl_typesupport_c, type_description_interfaces.type_description_interfaces_s__rosidl_typesupport_c, std_msgs.std_msgs_s__rosidl_typesupport_c (total: 19)
Segmentation fault (core dumped)

Expected behavior

No Segmentation Fault, perhaps at worst an rclpy._rclpy_pybind11.InvalidHandle exception (which does sometimes happen instead of a segmentation fault).

Actual behavior

Segmentation Fault

Additional information

While trying to create a minimal reproduction script, it seems that this may be a race-condition and thus the script tries repeatedly to more reliably cause the problem. This issue seems to be likely enough to happen though, that it happens almost every time one of our heavier LifecycleNodes in our system is shutting down or cleaning up.
However in the reproduction script, the number of topics does not seem to affect reproduction reliability (changing num_topics to 1, seg faults at the same rate as 10 for example).
We previously were using just SingleThreadedExecutor which worked fine (except for some performance issues, leading us to testing the EventsExectutor).

Using publishers vs subscribers seems to not matter, and seems to be primarily related to the added event handler waitables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions