BehaviorTree / BehaviorTree.CPP

Behavior Trees Library in C++. Batteries included.
https://www.behaviortree.dev
MIT License
3.03k stars 665 forks source link

BT::Blackboard::set<>() crash from pthread_mutex_lock #844

Closed yanfushi closed 4 months ago

yanfushi commented 4 months ago

Hello, I want to set an nav_msgs::msg::path into blackboard in a control node (similar with pipeline_sequence)

while (current_childidx == 0) { auto status = childrennodes[current_childidx]->executeTick(); switch (status) { case BT::NodeStatus::FAILURE: case BT::NodeStatus::SUCCESS: { ControlNode::haltChildren(); nav_msgs::msg::Path empty_path; config().blackboard->set("lpath", empty_path); last_childidx = current_childidx; current_childidx = 1; return BT::NodeStatus::RUNNING; break; } ... and got a backtrace like this [planner_and_controller_server-6] E0703 16:21:56.211638 195800 log_comm.h:104] [planner_and_controller_server] Aborted at 1719994916 (unix time) try "date -d @1719994916" if you are using GNU date [planner_and_controller_server-6] E0703 16:21:56.217368 195800 log_comm.h:104] [planner_and_controller_server] PC: @ 0x0 (unknown) [planner_and_controller_server-6] E0703 16:21:56.217739 195800 log_comm.h:104] [planner_and_controller_server] SIGSEGV (@0x40) received by PID 195450 (TID 0x7f630a7fc700) from PID 64; stack trace: [planner_and_controller_server-6] E0703 16:21:56.221498 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae0f5420 (unknown) [planner_and_controller_server-6] E0703 16:21:56.224429 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae0ebfc4 __GI___pthread_mutex_lock [planner_and_controller_server-6] E0703 16:21:56.228415 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63afad6ee0 BT::Blackboard::set<>() [planner_and_controller_server-6] E0703 16:21:56.229254 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f634fefdbb0 nav2_behavior_tree::CollectTaskSequence::tick() [planner_and_controller_server-6] E0703 16:21:56.233356 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae2fcf2a BT::TreeNode::executeTick() [planner_and_controller_server-6] E0703 16:21:56.236567 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae31c3a8 BT::ReactiveFallback::tick() [planner_and_controller_server-6] E0703 16:21:56.239871 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae2fcf2a BT::TreeNode::executeTick() [planner_and_controller_server-6] E0703 16:21:56.243667 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae31ca86 BT::SequenceNode::tick() [planner_and_controller_server-6] E0703 16:21:56.247471 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae2fcf2a BT::TreeNode::executeTick() [planner_and_controller_server-6] E0703 16:21:56.250717 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae31c3a8 BT::ReactiveFallback::tick() [planner_and_controller_server-6] E0703 16:21:56.253538 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae2fcf2a BT::TreeNode::executeTick() [planner_and_controller_server-6] E0703 16:21:56.256441 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae31be3a BT::ReactiveSequence::tick() [planner_and_controller_server-6] E0703 16:21:56.260146 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63ae2fcf2a BT::TreeNode::executeTick() [planner_and_controller_server-6] E0703 16:21:56.263854 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63adaf811f nav2_behavior_tree::BehaviorTreeEngine::run() [planner_and_controller_server-6] E0703 16:21:56.267549 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63afa90bf8 nav2_bt_navigator::BtNavigator::bmTaskStart() [planner_and_controller_server-6] E0703 16:21:56.270327 195800 log_comm.h:104] [planner_and_controller_server] @ 0x7f63afac0422 nav2_util::SimpleActionServer<>::work()

facontidavide commented 4 months ago

first, I strongly disourage using config().blackboard->set you must use Output/ Input Ports as explained in the tutorials.

Using the blackboard directly is an antipattern.

Second. please provide a Nav2 and possibly ROS independent way to reproduce the issue (full source code) or I will not be able to debug it.

I will mark it as "wontfix" until you provide a way to reproduce it.

yanfushi commented 4 months ago

Thanks for reply, I have figured out this problem a11e5ca5-3b01-4cad-8fdb-3965842aad48 I solved this problem by moving "behaviortree_cpp_v3/bt_factory.h" from hpp file to cpp file. But I dont know the reason. I will close the problem tomorrow.