Skip to content

Commit

Permalink
Fix 'basic_string::_M_construct null not valid' exception(#4341)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aosmw committed Aug 10, 2024
1 parent 5ecdc9a commit bcb0638
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void BtActionServer<ActionT>::cleanErrorCodes()
name = error_code_name_prefix + "_error_code";
blackboard_->set<unsigned short>(name, 0); //NOLINT
name = error_code_name_prefix + "_error_msg";
blackboard_->set<std::string>(name, 0); //NOLINT
blackboard_->set<std::string>(name, "");
}
}

Expand Down

0 comments on commit bcb0638

Please sign in to comment.