Skip to content

[25753] Fix for XCDR2 map member header - #368

Merged
MiguelCompany merged 2 commits into
masterfrom
bugfix/xcdr2-map-member-header
Dec 2, 2026
Merged

MiguelCompany merged 2 commits into
masterfrom
bugfix/xcdr2-map-member-header

Conversation

@ZakariaTalbi

@ZakariaTalbi ZakariaTalbi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

An std::map with string keys and primitive values failed to deserialize as a member of a mutable struct with XCDRv2. Maps with other key types, or in structs which are not mutable, worked.

Serializing a string sets serialized_member_size_, which tells the member header that the data starts with its own size. The map overload for primitive values never reset it, so the map length was announced as the member size in bytes. The flag is now reset after the map, in both Cdr and CdrSizeCalculator

@Mergifyio backport 2.4.x 2.3.x 2.2.x

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • N/A Any new/modified methods have been properly documented using Doxygen.
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: CI pass and failing tests are unrelated with the changes.

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
@ZakariaTalbi ZakariaTalbi changed the title Bugfix/xcdr2 map member header [25753] Fix for XCDR2 map member header Nov 26, 2026
@ZakariaTalbi
ZakariaTalbi requested review from richiprosima and removed request for richiprosima November 26, 2026 09:20
@MiguelCompany MiguelCompany added this to the v2.5.1 milestone Dec 2, 2026

@MiguelCompany MiguelCompany left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MiguelCompany
MiguelCompany merged commit 26399d6 into master Dec 2, 2026
21 checks passed
@MiguelCompany
MiguelCompany deleted the bugfix/xcdr2-map-member-header branch December 2, 2026 13:18
@MiguelCompany

Copy link
Copy Markdown
Member

@Mergifyio backport 2.4.x 2.3.x 2.2.x

@mergify

mergify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

backport 2.4.x 2.3.x 2.2.x

✅ Backports have been created

Details

MiguelCompany added a commit that referenced this pull request Dec 2, 2026
* Fix for XCDR2 map member header (#368)

* Add regression test for maps with string keys in XCDRv2 mutable members

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

* Stop joining map length with NEXTINT when keys are strings

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
(cherry picked from commit 26399d6)

* Fix uncrustify

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
MiguelCompany added a commit that referenced this pull request Dec 2, 2026
* Fix for XCDR2 map member header (#368)

* Add regression test for maps with string keys in XCDRv2 mutable members

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

* Stop joining map length with NEXTINT when keys are strings

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
(cherry picked from commit 26399d6)

* Fix uncrustify

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
MiguelCompany added a commit that referenced this pull request Dec 2, 2026
* Fix for XCDR2 map member header (#368)

* Add regression test for maps with string keys in XCDRv2 mutable members

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

* Stop joining map length with NEXTINT when keys are strings

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
(cherry picked from commit 26399d6)

* Fix uncrustify

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants