DataWriter cannot serialize (write) DynamicData struct with inheritance [13363]
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
- Define DynamicData struct with inheritance in the XML.
- Create a topic for appropriate type, register type for participant, create readers and writers etc.
- 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>
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.
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?
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.