ros-industrial / ros2_canopen

CANopen driver framework for ROS2

Home Page:https://ros-industrial.github.io/ros2_canopen/manual/rolling/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ConfigurationManager::get_entry()` optional return value is not checked

roncapat opened this issue · comments

Describe the bug
The software can crash in a very uninformative way if ever the get_entry() call fails internally. In fact, the return value is std::optional and it may happen to not contain a valid object.

[ros2_control_node-1] [INFO] [1704363943.705185838] [yaml-cpp]: Failed to load entry "driver" for device "" 
[ros2_control_node-1] terminate called after throwing an instance of 'std::bad_optional_access'
[ros2_control_node-1]   what():  bad optional access

Expected behavior
Return value of get_entry() to be cheched for existence before accessing, graceful fail/shutdown with context-aware error message / hint for the user if available to help fix configuration (fo example).

Setup:

  • OS: Ubuntu 22.04
  • ROS-Distro: rolling
  • Branch/Commit: master

Good point, we should fix this.