eclipse-cyclonedds/cyclonedds-cxx

CycloneDDS crashes when using typedef sequences

Closed this issue · 5 comments

Hi, we are using CycloneDDS-CXX 0.10.2 with the following IDL:

At runtime ReportRecordingStatus1 crashes and ReportRecordingStatus2 works fine.

module HelloWorldData
{
    typedef sequence<string> StringListType;

    struct ReportRecordingStatus1
    {
        StringListType InProgressRecordingsList;
    };

    struct ReportRecordingStatus2
    {
        sequence<string> InProgressRecordingsList;
    };
};
=== [Publisher] Create writer.
1676386490.708493 [0] HWD_Status: determined enp0s3 (udp/10.0.2.31) as highest quality interface, selected for automatic interface.
on_publication_matched, current_count: 1
=== [Publisher] Write sample.
=== [Publisher] Write sample with contents.
terminate called after throwing an instance of 'dds::core::InvalidArgumentError'
  what():  Error Bad Parameter - write failed.
===============================================================================
Context     : void org::eclipse::cyclonedds::pub::AnyDataWriterDelegate::write
Node        : UnknownNode

fish: './HWD_Status1_publisher' terminated by signal SIGABRT (Abort)

Here is the logfile from cyclone and the sources:
cyclone_error.zip

@eboasson is this a known bug?

@reicheratwork for me it still fails on current master, and it looks like the generated code for the two types is nearly the same, but if one works and the other fails then surely there must be something significant in the difference. Would you be willing to take a look?

We found out that the crash is new in cyclone version 0.10.2 with version 0.9.1 it works fine.

@reicheratwork for me it still fails on current master, and it looks like the generated code for the two types is nearly the same, but if one works and the other fails then surely there must be something significant in the difference. Would you be willing to take a look?

@trittsv, @eboasson, taking a look at it right now...
It looks the exception is caused by the serialization failing.
This is caused by the write operation not getting a large enough buffer, which in turn is caused by the function get_serialized_size not returning the correct value due to the topic trait for it being self contained (TopicTraits::isSelfContained) not returning the correct value.
In the case of the type ReportRecordingStatus1 (the one with the typedef of the sequence) this returns true, while this obviously should return false.
On the other hand, for the type ReportRecordingStatus2 (the one with the direct definition), this does return false, as it should.

Working on a fix.

Have made a PR for the fix here

Hey @reicheratwork @eboasson we just tested the changes (#369 ) in our software. It works fine 😃 From our perspective it can be merged. Thank you very much 🥳