Description
Hello @facontidavide,
We found the following deadlock using behaviortree_cpp
version 3.6.1.
It deadlocks in the following case using the newly introduced entry_mutex_
from 06a1f4c.
Lets think about the following two concurrent threads:
Thread A calls Blackboard::set()
Thread A locks mutex_
Thread B calls TreeNode::getInput()
Thread B locks entry_mutex_
Thread A waits for entry_mutex_
Thread B waits for mutex_
The order of locking introduces the deadlock.
Mitigation:
In Blackboard::set()
first lock entry_mutex_
then lock mutex_
.
Thread A calls Blackboard::set()
Thread A locks entry_mutex_
Thread B calls TreeNode::getInput()
Thread B waits for entry_mutex_
Thread A locks mutex_
Thread A releases mutex_
and entry_mutex_
Thread B locks entry_mutex_
Thread B locks mutex_
Thread B releases mutex_
and entry_mutex_
Thanks in advance!