From bcb063899a1ff6aa0d5ecb542db6dd704c49f234 Mon Sep 17 00:00:00 2001 From: Mike Wake Date: Sat, 10 Aug 2024 21:00:15 +1000 Subject: [PATCH] Fix 'basic_string::_M_construct null not valid' exception(#4341) This was tough to spot. The nav2_system_tests waypoint follower provided a reproducable test Found out how to run just the waypoint_follower test colcon test --packages-select nav2_system_tests --ctest-args -N --event-handler console_direct+ | grep waypoint_follower changed src/navigation2/nav2_bringup/launch/navigation_launch.py to start nav2_bt_navigator Node with + prefix=['gnome-terminal -- gdb -ex run --args'], + respawn=False, Trying to use gdb to catch where the exception was thrown is too slow and the test gives up on itself. I found the relevant throw std::logic_error on my system by writing tiny program and breaking on std::logic_error int main() { const char *a = nullptr; try { std::string b(a); } catch (const std::logic_error &ex) { std::cout << "logic_error:" << ex.what() << std::endl; } catch (const std::exception &ex) { std::cout << "some other type:" << ex.what() << std::endl; } } Turns out it get thrown here on my system /usr/include/c++/11/bits/basic_string.tcc:212 Created ~/.gdbinit set breakpoint pending on break /usr/include/c++/11/bits/basic_string.tcc:212 This specific breakpoint on a line works fast enough for the integration test to throw the 'basic_string::_M_construct null not valid' and the silly initialisation mistake to be found. Signed-off-by: Mike Wake --- .../include/nav2_behavior_tree/bt_action_server_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp index 35872ea4f4a..5f37d794628 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp @@ -379,7 +379,7 @@ void BtActionServer::cleanErrorCodes() name = error_code_name_prefix + "_error_code"; blackboard_->set(name, 0); //NOLINT name = error_code_name_prefix + "_error_msg"; - blackboard_->set(name, 0); //NOLINT + blackboard_->set(name, ""); } }