Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic types array of struct segmentation fault [9144] #1260

Closed
mdnasr opened this issue Jun 16, 2020 · 2 comments
Closed

Dynamic types array of struct segmentation fault [9144] #1260

mdnasr opened this issue Jun 16, 2020 · 2 comments
Assignees

Comments

@mdnasr
Copy link

mdnasr commented Jun 16, 2020

Domain::registerDynamicType crash with segmentation fault when data type contain array of structure. I have tried with both XML Types and Code types producing the same failure.

Current Behavior

The type.xml file:

<types>
  <type>
    <struct name="ChildStruct">
      <member name="index" type="uint32"/>
      <member name="message" type="string"/>
    </struct>
  </type>
  <type>
    <struct name="HelloWorld">
      <member name="child_struct" type="nonBasic" nonBasicTypeName="ChildStruct" arrayDimensions="2"/>
    </struct>
  </type>
</types>

Steps to Reproduce

Using the XML file above with project examples/C++/DDS/DynamicHelloWorldExample will produce the error but edit HelloWorldPublisher.cpp to remove any value intialization.

bool HelloWorldPublisher::init()
{
    if (eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK !=
            eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLFile("example_type.xml"))
    {
        std::cout << "Cannot open XML file \"example_type.xml\". Please, run the publisher from the folder "
                  << "that contatins this XML file." << std::endl;
        return false;
    }

    eprosima::fastrtps::types::DynamicType_ptr dyn_type =
            eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName("HelloWorld")->build();
    TypeSupport m_type(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type));
    m_Hello = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type);

    DomainParticipantQos pqos;
    pqos.name("Participant_pub");
    mp_participant = DomainParticipantFactory::get_instance()->create_participant(0, pqos);

    if (mp_participant == nullptr)
    {
        return false;
    }

    //REGISTER THE TYPE
    m_type.get()->auto_fill_type_information(false);
    m_type.get()->auto_fill_type_object(true);

    m_type.register_type(mp_participant);
...

Also I have tried with creating types myself with the same error. Using examples/C++/DynamicHelloWorldExample edit in HelloWorldPublisher.cpp

bool HelloWorldPublisher::init()
{
    // Create basic builders
    DynamicTypeBuilder_ptr builder(DynamicTypeBuilderFactory::get_instance()->create_struct_builder());

    // Add members to the struct.
    builder->add_member(0, "index", DynamicTypeBuilderFactory::get_instance()->create_uint32_type());
    builder->add_member(1, "message", DynamicTypeBuilderFactory::get_instance()->create_string_type());
    DynamicType_ptr struct_type = builder->build();

    DynamicTypeBuilder_ptr parent_builder = DynamicTypeBuilderFactory::get_instance()->create_struct_builder();
    parent_builder->add_member(0, "child_struct", struct_type);
    parent_builder->add_member(1, "second", DynamicTypeBuilderFactory::get_instance()->create_int32_type());

    std::vector<uint32_t> lengths = {2};
    DynamicTypeBuilder_ptr array = DynamicTypeBuilderFactory::get_instance()->create_array_builder(&(*parent_builder), lengths);
    array->set_name("HelloWorld");

    DynamicType_ptr dynType = array->build();

    m_DynType.SetDynamicType(dynType);
    m_DynHello = DynamicDataFactory::get_instance()->create_data(dynType);

    ParticipantAttributes PParam;
    PParam.rtps.setName("DynHelloWorld_pub");
    mp_participant = Domain::createParticipant(PParam, (ParticipantListener*)&m_part_list);

...

System information

  • Fast-RTPS version: 2.0.0 1df91c1
  • OS: Ubuntu 16.04
@bjarnisig
Copy link

This is probably very related to #1243

@EduPonz EduPonz changed the title Dynamic types array of struct segmentation fault Dynamic types array of struct segmentation fault [9144] Aug 28, 2020
@jparisu jparisu self-assigned this Sep 16, 2021
@jparisu
Copy link
Contributor

jparisu commented Sep 17, 2021

Thank you for this information.
This bug has been tagged and it will be solved in PR #2207 ASAP.
Please, follow this topic in issue #2184 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants