Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectionHandler::registerHandle() does not handle null pointer, causing segmentation fault #1374

Open
zhihaoshang opened this issue Apr 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@zhihaoshang
Copy link

Operating System:

Linux shangzh-VMware-Virtual-Platform 6.11.0-19-generic #19~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 17 11:51:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

ROS version or commit hash:

ros2 jazzy

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

rviz

'ros2 doctor --report' output

ros2 doc --report
   NETWORK CONFIGURATION
inet         : 127.0.0.1
inet4        : ['127.0.0.1']
inet6        : ['::1']
netmask      : 255.0.0.0
device       : lo
flags        : 73<RUNNING,UP,LOOPBACK>
mtu          : 65536
inet         : 192.168.148.137
inet4        : ['192.168.148.137']
ether        : 00:0c:29:be:c8:19
inet6        : ['fe80::20c:29ff:febe:c819%ens33']
netmask      : 255.255.255.0
device       : ens33
flags        : 4163<RUNNING,MULTICAST,UP,BROADCAST>
mtu          : 1500
broadcast    : 192.168.148.255

   PACKAGE VERSIONS
rqt_bag_plugins                           : latest=1.5.4, local=1.5.4
rosbag2                                   : latest=0.26.6, local=0.26.6
rosbag2_storage_default_plugins           : latest=0.26.6, local=0.26.6
rosbag2_storage_mcap                      : latest=0.26.6, local=0.26.6
rosbag2_compression_zstd                  : latest=0.26.6, local=0.26.6
mcap_vendor                               : latest=0.26.6, local=0.26.6
zstd_vendor                               : latest=0.26.6, local=0.26.6
rviz_visual_testing_framework             : latest=14.1.8, local=14.1.7
rviz2                                     : latest=14.1.8, local=14.1.7
rviz_default_plugins                      : latest=14.1.8, local=14.1.7
rviz_common                               : latest=14.1.8, local=14.1.7
rqt_bag                                   : latest=1.5.4, local=1.5.4
rosbag2_examples_py                       : latest=0.26.6, local=0.26.6
launch_testing_examples                   : latest=0.19.5, local=0.19.4
ros2bag                                   : latest=0.26.6, local=0.26.6
rosbag2_py                                : latest=0.26.6, local=0.26.6
rosbag2_transport                         : latest=0.26.6, local=0.26.6
rosbag2_storage_sqlite3                   : latest=0.26.6, local=0.26.6
rosbag2_examples_cpp                      : latest=0.26.6, local=0.26.6
rosbag2_compression                       : latest=0.26.6, local=0.26.6
rosbag2_cpp                               : latest=0.26.6, local=0.26.6
rosbag2_storage                           : latest=0.26.6, local=0.26.6
image_common                              : latest=5.1.5, local=5.1.5
camera_info_manager                       : latest=5.1.5, local=5.1.5
camera_calibration_parsers                : latest=5.1.5, local=5.1.5
yaml_cpp_vendor                           : latest=9.0.1, local=9.0.1
interactive_markers                       : latest=2.5.4, local=2.5.4
common_interfaces                         : latest=5.3.6, local=5.3.5
visualization_msgs                        : latest=5.3.6, local=5.3.5
dummy_robot_bringup                       : latest=0.33.5, local=0.33.5
robot_state_publisher                     : latest=3.3.3, local=3.3.3
kdl_parser                                : latest=2.11.0, local=2.11.0
urdf                                      : latest=2.10.0, local=2.10.0
urdf_parser_plugin                        : latest=2.10.0, local=2.10.0
turtlesim                                 : latest=1.8.3, local=1.8.3
trajectory_msgs                           : latest=5.3.6, local=5.3.5
tracetools_test                           : latest=8.2.3, local=8.2.3
tracetools_launch                         : latest=8.2.3, local=8.2.3
topic_statistics_demo                     : latest=0.33.5, local=0.33.5
topic_monitor                             : latest=0.33.5, local=0.33.5
pendulum_control                          : latest=0.33.5, local=0.33.5
tlsf_cpp                                  : latest=0.17.1, local=0.17.0
geometry2                                 : latest=0.36.9, local=0.36.8
tf2_tools                                 : latest=0.36.9, local=0.36.8
tf2_sensor_msgs                           : latest=0.36.9, local=0.36.8
test_tf2                                  : latest=N/A, local=0.36.8
tf2_kdl                                   : latest=0.36.9, local=0.36.8
tf2_geometry_msgs                         : latest=0.36.9, local=0.36.8
examples_tf2_py                           : latest=0.36.9, local=0.36.8
tf2_ros_py                                : latest=0.36.9, local=0.36.8
tf2_eigen                                 : latest=0.36.9, local=0.36.8
tf2_bullet                                : latest=0.36.9, local=0.36.8
tf2_ros                                   : latest=0.36.9, local=0.36.8
tf2_py                                    : latest=0.36.9, local=0.36.8
tf2_msgs                                  : latest=0.36.9, local=0.36.8
tf2_eigen_kdl                             : latest=0.36.9, local=0.36.8
laser_geometry                            : latest=2.7.0, local=2.7.0
tf2                                       : latest=0.36.9, local=0.36.8
test_tracetools                           : latest=N/A, local=8.2.3
rosbag2_test_common                       : latest=0.26.6, local=0.26.6
test_msgs                                 : latest=2.0.2, local=2.0.2
test_communication                        : latest=N/A, local=0.20.2
stereo_msgs                               : latest=5.3.6, local=5.3.5
std_srvs                                  : latest=5.3.6, local=5.3.5
shape_msgs                                : latest=5.3.6, local=5.3.5
examples_rclpy_pointcloud_publisher       : latest=0.19.5, local=0.19.4
sensor_msgs_py                            : latest=5.3.6, local=5.3.5
quality_of_service_demo_py                : latest=0.33.5, local=0.33.5
quality_of_service_demo_cpp               : latest=0.33.5, local=0.33.5
point_cloud_transport_py                  : latest=4.0.3, local=4.0.3
point_cloud_transport                     : latest=4.0.3, local=4.0.3
map_msgs                                  : latest=2.4.1, local=2.4.1
intra_process_demo                        : latest=0.33.5, local=0.33.5
image_transport                           : latest=5.1.5, local=5.1.5
image_tools                               : latest=0.33.5, local=0.33.5
dummy_sensors                             : latest=0.33.5, local=0.33.5
camera_info_manager_py                    : latest=5.1.5, local=5.1.5
sensor_msgs                               : latest=5.3.6, local=5.3.5
rqt_plot                                  : latest=1.4.2, local=1.4.2
ros2cli_common_extensions                 : latest=0.3.0, local=0.3.0
ros2doctor                                : latest=0.32.3, local=0.32.2
dummy_map_server                          : latest=0.33.5, local=0.33.5
nav_msgs                                  : latest=5.3.6, local=5.3.5
message_filters                           : latest=4.11.5, local=4.11.4
logging_demo                              : latest=0.33.5, local=0.33.5
lifecycle_py                              : latest=0.33.5, local=0.33.5
lifecycle                                 : latest=0.33.5, local=0.33.5
diagnostic_msgs                           : latest=5.3.6, local=5.3.5
geometry_msgs                             : latest=5.3.6, local=5.3.5
examples_rclpy_minimal_subscriber         : latest=0.19.5, local=0.19.4
examples_rclpy_minimal_service            : latest=0.19.5, local=0.19.4
examples_rclpy_minimal_publisher          : latest=0.19.5, local=0.19.4
examples_rclpy_minimal_client             : latest=0.19.5, local=0.19.4
examples_rclpy_executors                  : latest=0.19.5, local=0.19.4
examples_rclcpp_wait_set                  : latest=0.19.5, local=0.19.4
examples_rclcpp_multithreaded_executor    : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_subscriber        : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_publisher         : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_composition       : latest=0.19.5, local=0.19.4
examples_rclcpp_cbg_executor              : latest=0.19.5, local=0.19.4
demo_nodes_py                             : latest=0.33.5, local=0.33.5
demo_nodes_cpp_native                     : latest=0.33.5, local=0.33.5
demo_nodes_cpp                            : latest=0.33.5, local=0.33.5
composition                               : latest=0.33.5, local=0.33.5
actionlib_msgs                            : latest=5.3.6, local=5.3.5
std_msgs                                  : latest=5.3.6, local=5.3.5
rqt                                       : latest=1.6.0, local=1.6.0
rqt_gui_cpp                               : latest=1.6.0, local=1.6.0
ros2lifecycle_test_fixtures               : latest=0.32.3, local=0.32.2
ros2component                             : latest=0.32.3, local=0.32.2
rclcpp_lifecycle                          : latest=28.1.8, local=28.1.6
action_tutorials_cpp                      : latest=0.33.5, local=0.33.5
rclcpp_components                         : latest=28.1.8, local=28.1.6
examples_rclcpp_minimal_action_server     : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_action_client     : latest=0.19.5, local=0.19.4
rclcpp_action                             : latest=28.1.8, local=28.1.6
examples_rclcpp_minimal_timer             : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_service           : latest=0.19.5, local=0.19.4
examples_rclcpp_minimal_client            : latest=0.19.5, local=0.19.4
examples_rclcpp_async_client              : latest=0.19.5, local=0.19.4
rclcpp                                    : latest=28.1.8, local=28.1.6
libstatistics_collector                   : latest=1.7.4, local=1.7.4
statistics_msgs                           : latest=2.0.2, local=2.0.2
sros2_cmake                               : latest=0.13.3, local=0.13.2
sros2                                     : latest=0.13.3, local=0.13.2
rqt_topic                                 : latest=1.7.3, local=1.7.3
rqt_srv                                   : latest=1.2.2, local=1.2.2
rqt_shell                                 : latest=1.2.2, local=1.2.2
rqt_service_caller                        : latest=1.2.1, local=1.2.1
rqt_reconfigure                           : latest=1.6.2, local=1.6.2
rqt_py_console                            : latest=1.2.2, local=1.2.2
rqt_publisher                             : latest=1.7.2, local=1.7.2
rqt_action                                : latest=2.2.0, local=2.2.0
rqt_msg                                   : latest=1.5.1, local=1.5.1
rqt_console                               : latest=2.2.1, local=2.2.1
rqt_py_common                             : latest=1.6.0, local=1.6.0
rqt_graph                                 : latest=1.5.4, local=1.5.4
rqt_gui_py                                : latest=1.6.0, local=1.6.0
rqt_gui                                   : latest=1.6.0, local=1.6.0
ros_testing                               : latest=0.6.0, local=0.6.0
ros2trace                                 : latest=8.2.3, local=8.2.3
ros2topic                                 : latest=0.32.3, local=0.32.2
ros2test                                  : latest=0.6.0, local=0.6.0
ros2param                                 : latest=0.32.3, local=0.32.2
ros2lifecycle                             : latest=0.32.3, local=0.32.2
ros2service                               : latest=0.32.3, local=0.32.2
ros2run                                   : latest=0.32.3, local=0.32.2
ros2launch                                : latest=0.26.7, local=0.26.6
ros2pkg                                   : latest=0.32.3, local=0.32.2
ros2node                                  : latest=0.32.3, local=0.32.2
ros2multicast                             : latest=0.32.3, local=0.32.2
ros2interface                             : latest=0.32.3, local=0.32.2
ros2action                                : latest=0.32.3, local=0.32.2
ros2cli                                   : latest=0.32.3, local=0.32.2
launch_testing_ros                        : latest=0.26.7, local=0.26.6
launch_ros                                : latest=0.26.7, local=0.26.6
examples_rclpy_minimal_action_server      : latest=0.19.5, local=0.19.4
examples_rclpy_minimal_action_client      : latest=0.19.5, local=0.19.4
examples_rclpy_guard_conditions           : latest=0.19.5, local=0.19.4
action_tutorials_py                       : latest=0.33.5, local=0.33.5
rclpy                                     : latest=7.1.4, local=7.1.3
rosgraph_msgs                             : latest=2.0.2, local=2.0.2
rosbag2_interfaces                        : latest=0.26.6, local=0.26.6
ros2cli_test_interfaces                   : latest=0.32.3, local=0.32.2
rcl_lifecycle                             : latest=9.2.5, local=9.2.4
rcl_action                                : latest=9.2.5, local=9.2.4
rcl                                       : latest=9.2.5, local=9.2.4
rmw_implementation                        : latest=2.15.5, local=2.15.5
rmw_fastrtps_dynamic_cpp                  : latest=8.4.2, local=8.4.2
rmw_fastrtps_cpp                          : latest=8.4.2, local=8.4.2
rmw_fastrtps_shared_cpp                   : latest=8.4.2, local=8.4.2
rmw_cyclonedds_cpp                        : latest=2.2.3, local=2.2.3
rmw_connextddsmicro                       : latest=N/A, local=0.22.1
rmw_connextdds                            : latest=0.22.1, local=0.22.1
rmw_connextdds_common                     : latest=0.22.1, local=0.22.1
rmw_dds_common                            : latest=3.1.0, local=3.1.0
composition_interfaces                    : latest=2.0.2, local=2.0.2
rcl_interfaces                            : latest=2.0.2, local=2.0.2
pendulum_msgs                             : latest=0.33.5, local=0.33.5
lifecycle_msgs                            : latest=2.0.2, local=2.0.2
example_interfaces                        : latest=0.12.0, local=0.12.0
action_tutorials_interfaces               : latest=0.33.5, local=0.33.5
rosidl_default_runtime                    : latest=1.6.0, local=1.6.0
rosidl_default_generators                 : latest=1.6.0, local=1.6.0
action_msgs                               : latest=2.0.2, local=2.0.2
unique_identifier_msgs                    : latest=2.5.0, local=2.5.0
type_description_interfaces               : latest=2.0.2, local=2.0.2
service_msgs                              : latest=2.0.2, local=2.0.2
builtin_interfaces                        : latest=2.0.2, local=2.0.2
rosidl_core_runtime                       : latest=0.2.0, local=0.2.0
rosidl_core_generators                    : latest=0.2.0, local=0.2.0
rosidl_generator_py                       : latest=0.22.0, local=0.22.0
ament_lint_common                         : latest=0.17.2, local=0.17.1
ament_cmake_uncrustify                    : latest=0.17.2, local=0.17.1
ament_uncrustify                          : latest=0.17.2, local=0.17.1
uncrustify_vendor                         : latest=3.0.1, local=3.0.0
tracetools_trace                          : latest=8.2.3, local=8.2.3
tracetools_read                           : latest=8.2.3, local=8.2.3
tracetools                                : latest=8.2.3, local=8.2.3
tlsf                                      : latest=0.9.0, local=0.9.0
qt_gui_core                               : latest=2.7.5, local=2.7.5
qt_gui_cpp                                : latest=2.7.5, local=2.7.5
pluginlib                                 : latest=5.4.2, local=5.4.2
tinyxml2_vendor                           : latest=0.9.1, local=0.9.1
test_tracetools_launch                    : latest=N/A, local=8.2.3
test_security                             : latest=N/A, local=0.20.2
test_ros2trace                            : latest=N/A, local=8.2.3
test_rmw_implementation                   : latest=N/A, local=2.15.5
test_rclcpp                               : latest=N/A, local=0.20.2
test_quality_of_service                   : latest=N/A, local=0.20.2
test_launch_testing                       : latest=N/A, local=3.4.3
test_launch_ros                           : latest=N/A, local=0.26.6
test_interface_files                      : latest=0.11.0, local=0.11.0
test_cli_remapping                        : latest=N/A, local=0.20.2
test_cli                                  : latest=N/A, local=0.20.2
qt_gui_app                                : latest=2.7.5, local=2.7.5
qt_gui                                    : latest=2.7.5, local=2.7.5
tango_icons_vendor                        : latest=0.3.0, local=0.3.0
sqlite3_vendor                            : latest=0.26.6, local=0.26.6
rcl_logging_spdlog                        : latest=3.1.1, local=3.1.1
spdlog_vendor                             : latest=1.6.1, local=1.6.1
shared_queues_vendor                      : latest=0.26.6, local=0.26.6
rviz_rendering_tests                      : latest=14.1.8, local=14.1.7
rviz_rendering                            : latest=14.1.8, local=14.1.7
rviz_ogre_vendor                          : latest=14.1.8, local=14.1.7
rviz_assimp_vendor                        : latest=14.1.8, local=14.1.7
rttest                                    : latest=0.17.1, local=0.17.0
rti_connext_dds_cmake_module              : latest=0.22.1, local=0.22.1
lttngpy                                   : latest=8.2.3, local=8.2.3
rpyutils                                  : latest=0.4.1, local=0.4.1
rosidl_typesupport_tests                  : latest=N/A, local=3.2.2
rosidl_typesupport_introspection_tests    : latest=N/A, local=4.6.5
rosidl_typesupport_cpp                    : latest=3.2.2, local=3.2.2
rosidl_typesupport_introspection_cpp      : latest=4.6.5, local=4.6.5
rosidl_typesupport_c                      : latest=3.2.2, local=3.2.2
rosidl_typesupport_introspection_c        : latest=4.6.5, local=4.6.5
rosidl_typesupport_fastrtps_c             : latest=3.6.1, local=3.6.1
rosidl_typesupport_fastrtps_cpp           : latest=3.6.1, local=3.6.1
rosidl_generator_cpp                      : latest=4.6.5, local=4.6.5
rosidl_runtime_cpp                        : latest=4.6.5, local=4.6.5
rosidl_dynamic_typesupport_fastrtps       : latest=0.1.0, local=0.1.0
rcl_yaml_param_parser                     : latest=9.2.5, local=9.2.4
rmw                                       : latest=7.3.2, local=7.3.2
rosidl_dynamic_typesupport                : latest=0.1.2, local=0.1.2
rosidl_runtime_c                          : latest=4.6.5, local=4.6.5
rosidl_generator_c                        : latest=4.6.5, local=4.6.5
rosidl_typesupport_interface              : latest=4.6.5, local=4.6.5
rosidl_runtime_py                         : latest=0.13.1, local=0.13.1
rosidl_generator_dds_idl                  : latest=0.11.1, local=0.11.1
rosidl_cmake                              : latest=4.6.5, local=4.6.5
rosidl_pycommon                           : latest=4.6.5, local=4.6.5
rosidl_generator_type_description         : latest=4.6.5, local=4.6.5
rosidl_parser                             : latest=4.6.5, local=4.6.5
rosidl_generator_tests                    : latest=N/A, local=4.6.5
rosidl_adapter                            : latest=4.6.5, local=4.6.5
rosidl_cli                                : latest=4.6.5, local=4.6.5
rosbag2_tests                             : latest=0.26.6, local=0.26.6
rosbag2_test_msgdefs                      : latest=0.26.6, local=0.26.6
ros_environment                           : latest=4.2.1, local=4.2.1
rmw_implementation_cmake                  : latest=7.3.2, local=7.3.2
resource_retriever                        : latest=3.4.3, local=3.4.3
class_loader                              : latest=2.7.0, local=2.7.0
rcpputils                                 : latest=2.11.2, local=2.11.1
rcl_logging_noop                          : latest=3.1.1, local=3.1.1
rcl_logging_interface                     : latest=3.1.1, local=3.1.1
rcutils                                   : latest=6.7.2, local=6.7.2
qt_gui_py_common                          : latest=2.7.5, local=2.7.5
qt_dotgraph                               : latest=2.7.5, local=2.7.5
python_qt_binding                         : latest=2.2.1, local=2.2.1
python_orocos_kdl_vendor                  : latest=0.5.1, local=0.5.1
launch_testing_ament_cmake                : latest=3.4.4, local=3.4.3
python_cmake_module                       : latest=0.11.1, local=0.11.1
pybind11_vendor                           : latest=3.1.3, local=3.1.2
performance_test_fixture                  : latest=0.2.1, local=0.2.1
launch_pytest                             : latest=3.4.4, local=3.4.3
launch_testing                            : latest=3.4.4, local=3.4.3
launch_yaml                               : latest=3.4.4, local=3.4.3
launch_xml                                : latest=3.4.4, local=3.4.3
launch                                    : latest=3.4.4, local=3.4.3
osrf_pycommon                             : latest=2.1.5, local=2.1.5
orocos_kdl_vendor                         : latest=0.5.1, local=0.5.1
mimick_vendor                             : latest=0.6.2, local=0.6.2
libyaml_vendor                            : latest=1.6.3, local=1.6.3
liblz4_vendor                             : latest=0.26.6, local=0.26.6
libcurl_vendor                            : latest=3.4.3, local=3.4.3
keyboard_handler                          : latest=0.3.1, local=0.3.1
gz_math_vendor                            : latest=0.0.8, local=0.0.8
gz_utils_vendor                           : latest=0.0.5, local=0.0.5
gz_cmake_vendor                           : latest=0.0.9, local=0.0.9
ament_cmake_ros                           : latest=0.12.0, local=0.12.0
ament_cmake_auto                          : latest=2.5.3, local=2.5.3
ament_cmake_gmock                         : latest=2.5.3, local=2.5.3
ament_cmake_gtest                         : latest=2.5.3, local=2.5.3
ament_cmake_google_benchmark              : latest=2.5.3, local=2.5.3
fastrtps_cmake_module                     : latest=3.6.1, local=3.6.1
eigen3_cmake_module                       : latest=0.3.0, local=0.3.0
domain_coordinator                        : latest=0.12.0, local=0.12.0
console_bridge_vendor                     : latest=1.7.1, local=1.7.1
ament_cmake_xmllint                       : latest=0.17.2, local=0.17.1
ament_xmllint                             : latest=0.17.2, local=0.17.1
ament_cmake_pyflakes                      : latest=0.17.2, local=0.17.1
ament_pyflakes                            : latest=0.17.2, local=0.17.1
ament_cmake_pycodestyle                   : latest=0.17.2, local=0.17.1
ament_pycodestyle                         : latest=0.17.2, local=0.17.1
ament_cmake_pep257                        : latest=0.17.2, local=0.17.1
ament_pep257                              : latest=0.17.2, local=0.17.1
ament_cmake_pclint                        : latest=0.17.2, local=0.17.1
ament_pclint                              : latest=0.17.2, local=0.17.1
ament_lint_auto                           : latest=0.17.2, local=0.17.1
ament_cmake                               : latest=2.5.3, local=2.5.3
ament_cmake_version                       : latest=2.5.3, local=2.5.3
ament_cmake_vendor_package                : latest=2.5.3, local=2.5.3
ament_cmake_pytest                        : latest=2.5.3, local=2.5.3
ament_cmake_mypy                          : latest=0.17.2, local=0.17.1
ament_cmake_lint_cmake                    : latest=0.17.2, local=0.17.1
ament_cmake_flake8                        : latest=0.17.2, local=0.17.1
ament_cmake_cpplint                       : latest=0.17.2, local=0.17.1
ament_cmake_cppcheck                      : latest=0.17.2, local=0.17.1
ament_cmake_copyright                     : latest=0.17.2, local=0.17.1
ament_cmake_clang_tidy                    : latest=0.17.2, local=0.17.1
ament_cmake_clang_format                  : latest=0.17.2, local=0.17.1
ament_cmake_test                          : latest=2.5.3, local=2.5.3
ament_cmake_target_dependencies           : latest=2.5.3, local=2.5.3
ament_cmake_python                        : latest=2.5.3, local=2.5.3
ament_cmake_export_dependencies           : latest=2.5.3, local=2.5.3
ament_cmake_libraries                     : latest=2.5.3, local=2.5.3
ament_cmake_include_directories           : latest=2.5.3, local=2.5.3
ament_cmake_gen_version_h                 : latest=2.5.3, local=2.5.3
ament_cmake_export_targets                : latest=2.5.3, local=2.5.3
ament_cmake_export_link_flags             : latest=2.5.3, local=2.5.3
ament_cmake_export_interfaces             : latest=2.5.3, local=2.5.3
ament_cmake_export_libraries              : latest=2.5.3, local=2.5.3
ament_cmake_export_include_directories    : latest=2.5.3, local=2.5.3
ament_cmake_export_definitions            : latest=2.5.3, local=2.5.3
ament_cmake_core                          : latest=2.5.3, local=2.5.3
ament_package                             : latest=0.16.3, local=0.16.3
ament_mypy                                : latest=0.17.2, local=0.17.1
ament_lint_cmake                          : latest=0.17.2, local=0.17.1
ament_flake8                              : latest=0.17.2, local=0.17.1
ament_copyright                           : latest=0.17.2, local=0.17.1
ament_lint                                : latest=0.17.2, local=0.17.1
ament_index_python                        : latest=1.8.1, local=1.8.1
ament_index_cpp                           : latest=1.8.1, local=1.8.1
ament_cpplint                             : latest=0.17.2, local=0.17.1
ament_cppcheck                            : latest=0.17.2, local=0.17.1
ament_clang_tidy                          : latest=0.17.2, local=0.17.1
ament_clang_format                        : latest=0.17.2, local=0.17.1

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-6.11.0-19-generic-x86_64-with-glibc2.39
release          : 6.11.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               : none
publisher count     : 0
subscriber count    : 0

Steps to reproduce issue

Environment

OS Version: Ubuntu 24.04
rviz version: ros2 jazzy
Compiler name and version number: Ubuntu clang version 18.1.3
Source or binary build?
source build
build options: --mixin asan-gcc

Description:

In the SelectionHandler::registerHandle() function, when context_ is nullptr, the function does not perform a null pointer check, which leads to a segmentation fault when dereferencing the null pointer. This issue affects the stability of the program, as it fails to provide proper error handling when an invalid pointer is passed.

Test Case

#include <gmock/gmock.h>
 #include <OgreManualObject.h>
 #include <OgreSceneNode.h>
 #include <OgreMaterialManager.h>
 #include <OgreWireBoundingBox.h>
 #include <memory>
 #include <vector>
 #include "rviz_common/interaction/selection_handler.hpp"
 #include "rviz_common/display_context.hpp"
 #include "selection_test_fixture.hpp"
 MATCHER_P(ContainsWireBoxWithBoundingBox, AABB, "") {
   for (const auto & box : arg) {
     if (box->getBoundingBox() == AABB) {
       return true;
     }
   }
   return false;
 }
 class SelectionHandlerFixture : public SelectionTestFixture
 {
 public:
   SelectionHandlerFixture()
   {
     using rviz_common::interaction::SelectionHandler;
     handler_ = rviz_common::interaction::createSelectionHandler<SelectionHandler>(context_.get());
   }
   Ogre::ManualObject * createManualObject()
   {
     static int count = 0;
     auto object = scene_manager_->createManualObject("ManualObject" + std::to_string(count++));
     object->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
     object->position(-2.0f, -2.0f, 0.0f);
     object->position(2.0f, -2.0f, 0.0f);
     object->position(2.0f, 2.0f, 0.0f);
     object->position(-2.0f, 2.0f, 0.0f);
     object->position(-2.0f, -2.0f, 0.0f);
     object->end();
     return object;
   }
   void findSimpleRenderablesAttached(
     Ogre::SceneNode * scene_node, std::vector<Ogre::MovableObject *> & objects)
   {
     auto attached_objects = scene_node->getAttachedObjects();
     for (const auto & object : attached_objects) {
       if (object->getMovableType() == "SimpleRenderable") {
         objects.push_back(object);
       }
     }
   }
   std::vector<Ogre::MovableObject *> findAllSimpleRenderables(Ogre::SceneNode * scene_node)
   {
     std::vector<Ogre::MovableObject *> objects;
     findSimpleRenderablesAttached(scene_node, objects);
     for (const auto child_node : scene_node->getChildren()) {
       auto child_scene_node = dynamic_cast<Ogre::SceneNode *>(child_node);
       findSimpleRenderablesAttached(child_scene_node, objects);
     }
     return objects;
   }
   std::shared_ptr<rviz_common::interaction::SelectionHandler> handler_;
 };
 
 TEST_F(SelectionHandlerFixture, createSelectionHandler_prevents_memory_leak_on_exception) {
  EXPECT_THROW({
    auto handler = rviz_common::interaction::createSelectionHandler<rviz_common::interaction::SelectionHandler>(nullptr);
  }, std::invalid_argument);  
}

Output

Running main() from gmock_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from SelectionHandlerFixture
[ RUN      ] SelectionHandlerFixture.createSelectionHandler_prevents_memory_leak_on_exception
[rviz_rendering:debug] Available Renderers(1): OpenGL Rendering Subsystem, at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:289
[rviz_rendering:info] Stereo is NOT SUPPORTED, at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:531
[rviz_rendering:info] OpenGl version: 4.3 (GLSL 4.3), at /home/shangzh/ros2_jazzy/src/ros2/rviz/rviz_rendering/src/rviz_rendering/render_system.cpp:272
AddressSanitizer:DEADLYSIGNAL
=================================================================
==419319==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x708bb87785ab bp 0x7fff520540a0 sp 0x7fff52053fc0 T0)
==419319==The signal is caused by a READ memory access.
==419319==Hint: address points to the zero page.
    #0 0x708bb87785ab in rviz_common::interaction::SelectionHandler::registerHandle() (/home/shangzh/ros2_jazzy/install/rviz_common/lib/librviz_common.so+0x7785ab) (BuildId: 39789ab887abf563a7a1d60c39fc9c650a624184)
    #1 0x5c9daa048a4a in std::shared_ptr<rviz_common::interaction::SelectionHandler> rviz_common::interaction::createSelectionHandler<rviz_common::interaction::SelectionHandler, decltype(nullptr)>(decltype(nullptr)) (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x139a4a) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #2 0x5c9daa04072c in SelectionHandlerFixture_createSelectionHandler_prevents_memory_leak_on_exception_Test::TestBody() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x13172c) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #3 0x5c9daa17d3db in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x26e3db) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #4 0x5c9daa16a745 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x25b745) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #5 0x5c9daa110d1b in testing::Test::Run() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x201d1b) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #6 0x5c9daa1124f7 in testing::TestInfo::Run() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x2034f7) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #7 0x5c9daa113850 in testing::TestSuite::Run() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x204850) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #8 0x5c9daa13a57b in testing::internal::UnitTestImpl::RunAllTests() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x22b57b) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #9 0x5c9daa180836 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x271836) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #10 0x5c9daa16d9e2 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x25e9e2) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #11 0x5c9daa136b85 in testing::UnitTest::Run() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x227b85) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #12 0x5c9daa0e1027 in RUN_ALL_TESTS() (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x1d2027) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #13 0x5c9daa0e0f73 in main (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x1d1f73) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)
    #14 0x708bb322a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #15 0x708bb322a28a in __libc_start_main_impl ../csu/libc-start.c:360
    #16 0x5c9daa0404b4 in _start (/home/shangzh/ros2_jazzy/build/rviz_common/selection_handler_test+0x1314b4) (BuildId: c0fa7f8e4a8615e6ffce9d9137547b4543050c33)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/shangzh/ros2_jazzy/install/rviz_common/lib/librviz_common.so+0x7785ab) (BuildId: 39789ab887abf563a7a1d60c39fc9c650a624184) in rviz_common::interaction::SelectionHandler::registerHandle()
==419319==ABORTING

Expected behavior

When context_ is nullptr, the function should throw a std::invalid_argument exception or another appropriate error to notify the caller that an invalid pointer has been passed.

The function should perform a validity check on the pointer to ensure it is valid before dereferencing, preventing access to invalid memory and ensuring the program runs smoothly.

Actual behavior

Without a null pointer check, if context_ is nullptr, SelectionHandler::registerHandle() attempts to access context_->getHandlerManager(), causing a segmentation fault when dereferencing the null pointer.

The expected exception cannot be caught during testing, and the program crashes directly, causing the test to fail.

Additional information

@zhihaoshang zhihaoshang added the bug Something isn't working label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant