open-rmf/rmf_ros2

redesignv2: building in debug mode triggers assert in nlohmann and crashes adapter for teleop commands

cnboonhan opened this issue · 1 comments

When building in debug mode ( using colcon build instead of colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release, assert clauses are not stripped. The following sequence of commands trigger a crash in the full control fleet adapter when using teleop commands:
using this exact vcs checkout my.repos.txt

Reproducible steps:

vcs import src < my.repos
colcon build

ros2 launch rmf_demos_ign office.launch.xml headless:=0 server_uri:=ws://localhost:8001 use_sim_time:=false finishing_request:=charge
ros2 run rmf_demos_tasks dispatch_teleop  -s coe

crash logs

[full_control-13] full_control: /usr/include/nlohmann/json.hpp:3401: const value_type& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::operator[](T*) const [with T = const char; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_reference = const nlohmann::basic_json<>&; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::value_type = nlohmann::basic_json<>]: Assertion `m_value.object->find(key) != m_value.object->end()' failed.
[ERROR] [full_control-13]: process has died [pid 2093909, exit code -6, cmd '/home/cnboonhan/workspaces/debug_ws/install/rmf_fleet_adapter/lib/rmf_fleet_adapter/full_control --ros-args -r __node:=tinyRobot_fleet_adapter --params-file /tmp/launch_params_250kojq6 --params-file /tmp/launch_params_qfr04f_3 --params-file /tmp/launch_params_bc2_3h54 --params-file /tmp/launch_params_j_qh7eph --params-file /tmp/launch_params_g13w8svb --params-file /tmp/launch_params_84y75pnc --params-file /tmp/launch_params_r2a8gd4z --params-file /tmp/launch_params_izbfm73r --params-file /tmp/launch_params_q_68zzat --params-file /tmp/launch_params_uh1ee4d5 --params-file /tmp/launch_params_v4bswlta --params-file /tmp/launch_params_c1hch75z --params-file /tmp/launch_params_hwnnlsaq --params-file /tmp/launch_params_how2u68f --params-file /tmp/launch_params_i7be84o3 --params-file /tmp/launch_params_69fxl7_0 --params-file /tmp/launch_params_uqt77l0b --params-file /tmp/launch_params_2g7khshy --params-file /tmp/launch_params_4orb8vpm --params-file /tmp/launch_params_80t_1ba5 --params-file /tmp/launch_params_bujrsjx1 --params-file /tmp/launch_params_m47ewaqy --params-file /tmp/launch_params_5jp25a4f --params-file /tmp/launch_params_r5va_22w --params-file /tmp/launch_params_chldxeob --params-file /tmp/launch_params_q2vvsuys --params-file /tmp/launch_params_snjqnu0o --params-file /tmp/launch_params_fww_1flr --params-file /tmp/launch_params_ji7pqupu --params-file /tmp/launch_params_sfq7dlj8 --params-file /tmp/launch_params_7zwfy48q'].
[rmf_task_dispatcher-11] [INFO] [1643953792.226966851] [rmf_dispatcher_node]: Task auction for [compose.dispatch-0] did not received any bids

This might be a more fundamental bug that is ignored when building in Release

Thanks for the detailed report!

The root cause was an earlier misunderstanding about how the operator[] behaves for nlohmann::json. We fixed it in most places, but it seems there were still a few spots it was lingering in. This particular case should be fixed now by 0c0a3f7.