Fast-DDS
Fast-DDS copied to clipboard
Double Free for DynamicData for Sequences of Nested Structs (with minimal example)
Is there an already existing issue for this?
- [X] I have searched the existing issues
Expected behavior
- Create a dynamic data consisting of a sequence/array of nested structs
- Populate that sequence with nested struct elements
- Exit cleanly
Current behavior
- Create a dynamic data consisting of a sequence/array of nested structs
- Populate that sequence with nested struct elements
- Exit cleanly <--- Errors print here
Specifically, the following error is printed per sequence/array element created.
[DYN_TYPES Error] Error deleting DynamicData. It isn't registered in the factory -> Function delete_data
Steps to reproduce
I've prepared a minimal example: methylDragon/fastdds-pr-minimal-examples
Once built, run:
cd build
./src/nested-sequences-bug/could_not_delete
The relevant code can be found here.
Fast DDS version/commit
FastDDS 2.8.x: https://github.com/eProsima/Fast-DDS/commit/78473a0de3d878a71565ee5d6c8e1e01c34beb70
The examples workspace is using that specific SHA in the submodule, for convenience.
Platform/Architecture
Other. Please specify in Additional context section.
Transport layer
Default configuration, UDPv4 & SHM
Additional context
This is on 22.04, but I don't think the platform matters in this case.
The error is being emitted from DynamicDataFactory's destructor call.
What I suspect is happening is, as each dynamic data is added to the sequence/array, the data gets registered once to the factory on creation. But on destruction, the factory destroys the instance, but the sequence/array destruction triggers a second destruction.
This causes the double free. (I think)
XML configuration file
No response
Relevant log output
nested_sequence:
[0] = <struct/bitset>
inner_uint32: 1
[1] = <struct/bitset>
inner_uint32: 2
2022-09-22 16:04:48.127 [DYN_TYPES Error] Error deleting DynamicData. It isn't registered in the factory -> Function delete_data
2022-09-22 16:04:48.127 [DYN_TYPES Error] Error deleting DynamicData. It isn't registered in the factory -> Function delete_data
### Network traffic capture
_No response_