Skip to content

Segmentation fault when substituting subtree #934

Open
@Isarm

Description

@Isarm

Describe the bug
Trying to add a substitution rule on a subtree results in a segmentation fault. Segfault happens inside factory.createTree()

How to Reproduce

TEST(MinimalExampleTest, minimalExampleTest) {
  BT::BehaviorTreeFactory factory;
  // Find all the XML files in a folder and register all of them.
  // We will use std::filesystem::directory_iterator
  using std::filesystem::directory_iterator;
  for (auto const& entry : directory_iterator(BT_TREES_PATH)) {
    if (entry.path().extension() == ".xml") {
      factory.registerBehaviorTreeFromFile(entry.path().string());
    }
  }
  BT::TestNodeConfig config;
  factory.addSubstitutionRule("child", config);

  BT::Tree tree = factory.createTree("Parent");
}

With these 2 trees inside BT_TREES_PATH:

<root BTCPP_format="4">
  <BehaviorTree ID="Parent" name="parent">
    <SubTree ID="ChildTree" name="child" />
  </BehaviorTree>
</root>
<root BTCPP_format="4">
  <BehaviorTree ID="Child">
    <AlwaysSuccess />
  </BehaviorTree>
</root>

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