You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting an invalid parameter override crashes the process and gives an uninformative error message.
Required Info:
Operating System: Ubuntu 22.04
Installation type: binaries
Version or commit hash: 5.3.1
DDS implementation: default
Client library (if applicable): rcl
Steps to reproduce issue
sudo apt install ros-humble-demo-nodes-cpp
ros2 run demo_nodes_cpp talker --ros-args -p bla
Expected behavior
An error message or warning informing about the missing value assignment should be shown. I.e. the message should say that -p bla is not a valid parameter override, but -p bla:=5 is.
Even better, the parameter bla should be set to uninitialised (ParameterType::PARAMETER_NOT_SET).
Actual behavior
Crash with:
[ERROR] [1660855233.229710370] [rcl]: Failed to parse global arguments
terminate called after throwing an instance of 'rclcpp::exceptions::RCLInvalidROSArgsError'
what(): failed to initialize rcl: Couldn't parse parameter override rule: '-p bla'. Error: Expected lexeme type (22) not found, search ended at index 3, at ./src/rcl/lexer_lookahead.c:239, at ./src/rcl/arguments.c:343
[ros2run]: Aborted
The text was updated successfully, but these errors were encountered:
I think that this is because application does not catch the exception from rclcpp::init (rcl_init)
# ros2 run demo_nodes_cpp add_two_ints_client 1 2 --ros-args -p bla
[ERROR] [1660931840.357026857] [rcl]: Failed to parse global arguments
terminate called after throwing an instance of 'rclcpp::exceptions::RCLInvalidROSArgsError'what(): failed to initialize rcl: Couldn't parse parameter override rule: '-p bla'. Error: Expected lexeme type (22) not found, search ended at index 3, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/lexer_lookahead.c:239, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/arguments.c:343[ros2run]: Aborted
this can be with following patch,
diff --git a/demo_nodes_cpp/src/services/add_two_ints_client.cpp b/demo_nodes_cpp/src/services/add_two_ints_client.cpp
index 8442801..b0cdf0d 100644
--- a/demo_nodes_cpp/src/services/add_two_ints_client.cpp+++ b/demo_nodes_cpp/src/services/add_two_ints_client.cpp@@ -43,7 +43,12 @@ int main(int argc, char ** argv)
// Force flush of the stdout buffer.
setvbuf(stdout, NULL, _IONBF, BUFSIZ);
- rclcpp::init(argc, argv);+ try {+ rclcpp::init(argc, argv);+ } catch (const std::exception & exception) {+ RCLCPP_ERROR(rclcpp::get_logger("rclcpp"), exception.what());+ return EXIT_FAILURE;+ }
auto node = rclcpp::Node::make_shared("add_two_ints_client");
# ros2 run demo_nodes_cpp add_two_ints_client 1 2 --ros-args -p bla
[ERROR] [1660931652.776928271] [rcl]: Failed to parse global arguments
[ERROR] [1660931652.776993285] [rclcpp]: failed to initialize rcl: Couldn't parse parameter override rule: '-p bla'. Error: Expected lexeme type (22) not found, search ended at index 3, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/lexer_lookahead.c:239, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/arguments.c:343[ros2run]: Process exited with failure 1
[rclcpp]: failed to initialize rcl: Couldn't parse parameter override rule: '-p bla'. Error: Expected lexeme type (22) not found, search ended at index 3, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/lexer_lookahead.c:239, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/arguments.c:343
I still think this error message isn't as useful as it could be. It's exposing a low-level detail (the lexer parse error), rather than the higher-level "you provided an parameter argument that is missing :=", which is arguably more useful to the end-user.
Bug report
Setting an invalid parameter override crashes the process and gives an uninformative error message.
Required Info:
Steps to reproduce issue
sudo apt install ros-humble-demo-nodes-cpp
ros2 run demo_nodes_cpp talker --ros-args -p bla
Expected behavior
An error message or warning informing about the missing value assignment should be shown. I.e. the message should say that
-p bla
is not a valid parameter override, but-p bla:=5
is.Even better, the parameter
bla
should be set to uninitialised (ParameterType::PARAMETER_NOT_SET
).Actual behavior
Crash with:
The text was updated successfully, but these errors were encountered: