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

DataWriter cannot serialize (write) DynamicData struct with inheritance [13363] #2375

Closed
lexamor opened this issue Dec 22, 2021 · 3 comments
Closed
Labels
need more info Issue that requires more info from contributor

Comments

@lexamor
Copy link

lexamor commented Dec 22, 2021

Data writer reports serialization errors while writing data with inheritance.

Expected Behavior

DataWriter (and reader as well) should be able to work with DynamicData types defined in the XML with inheritance.

Current Behavior

Data writers cannot write data type payload (e.g. struct) with inheritance.

Steps to Reproduce

  1. Define DynamicData struct with inheritance in the XML.
  2. Create a topic for appropriate type, register type for participant, create readers and writers etc.
  3. Try to write data using DataWriter.

System information

  • Fast-RTPS version: 2.4.0
  • OS: Ubuntu 20.04

Additional context

Seems that the size of parent dynamic data type is ignored while serialized size calculation. The following hotfix, seems, works for me, but unfortunately I'm not sure if it is enough or how it can affect other functionality.

diff --git a/src/cpp/dynamic-types/DynamicData.cpp b/src/cpp/dynamic-types/DynamicData.cpp
index 4536ccbbe..cfa8de39b 100644
--- a/src/cpp/dynamic-types/DynamicData.cpp
+++ b/src/cpp/dynamic-types/DynamicData.cpp
@@ -6181,6 +6181,10 @@ size_t DynamicData::getMaxCdrSerializedSize(
         case TK_STRUCTURE:
         case TK_BITSET:
         {
+            if(auto base_type{type->get_base_type()}){
+                current_alignment += getMaxCdrSerializedSize(base_type);
+            }
+
             for (auto it = type->member_by_id_.begin(); it != type->member_by_id_.end(); ++it)
             {
                 if (!it->second->descriptor_.annotation_is_non_serialized())

Additional resources

  • XML profiles file
<struct name="ParentStruct">
    <member name="first" type="int32"/>
    <member name="second" type="int64"/>
</struct>
<struct name="ChildStruct" baseType="ParentStruct">
    <member name="third" type="int32"/>
    <member name="fourth" type="int64"/>
</struct>
@MiguelCompany MiguelCompany changed the title DataWriter cannot serialize (write) DynamicData struct with inheritance DataWriter cannot serialize (write) DynamicData struct with inheritance [13363] Jan 3, 2022
@JLBuenoLopez
Copy link
Contributor

There are several known issues related with Dynamic Types in Fast DDS. Thus, a refactor is being undertaken in order to fix the Dynamic Types implementation. It is expected to be released with Fast DDS v2.11.0 scheduled for June 2023.

@JLBuenoLopez JLBuenoLopez added the bug Issue to report a bug label Apr 13, 2023
@JLBuenoLopez JLBuenoLopez linked a pull request Apr 13, 2023 that will close this issue
13 tasks
@JesusPoderoso
Copy link
Contributor

Hi @lexamor, Fast DDS v3.0.0 has been released, including a Dynamic Types refactor that may have fixed your issue. Could you check if the problem persists?

@JesusPoderoso JesusPoderoso added need more info Issue that requires more info from contributor and removed bug Issue to report a bug labels Aug 29, 2024
@Mario-DL
Copy link
Member

Mario-DL commented Sep 5, 2024

As the Dynamic Types refactor has been already introduced in the latest Fast DDS v3.0.0, we internally agreed to close all Dynamic-Types related issues.
We elaborated a Migration guide to help with the upgrade process to this new major release.

Please, feel free to reopen it if the issue persists.

@Mario-DL Mario-DL closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Issue that requires more info from contributor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants