Skip to content

[Blackboard] Deadlock on concurrent set() and getInput(). #367

Closed
@FabianSchurig

Description

@FabianSchurig

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions