Skip to content

fix: size Lyrical primitive and string sequence fields correctly - #714

Open
rosterloh wants to merge 1 commit into
ros2-rust:mainfrom
rosterloh:fix/lyrical-sequence-field-size
Open

rosterloh wants to merge 1 commit into
ros2-rust:mainfrom
rosterloh:fix/lyrical-sequence-field-size

Conversation

@rosterloh

@rosterloh rosterloh commented Sep 23, 2026 •

Copy link
Copy Markdown

On Lyrical, reading a primitive or string sequence field through DynamicMessage panics:

panicked at rclrs/src/dynamic_message/field_access.rs:19:5:
assertion failed: bytes.len() >= std::mem::size_of::<T>()

MessageFieldInfo::size() reports every sequence as 24 bytes. Since ros2/rosidl#942, primitive and string sequences carry the rosidl_buffer tail and are 32 bytes (mirrored in ros2-rust/rosidl_runtime_rs#22). Message sequences are unchanged.

This PR sizes non-message sequences as Sequence<u8>, which has the right tail on every distro, so Humble/Jazzy/Kilted are unaffected. Adds a test that reads primitive and string sequences from test_msgs/UnboundedSequences; it fails on main under Lyrical.

Refs #659.

This pull request was assisted by: Claude:claude-opus-5-5

rosterloh added a commit to rosterloh/talos that referenced this pull request Sep 23, 2026
Point the Lyrical DynamicMessage known issue in AGENTS.md and CHANGELOG
at ros2-rust/ros2_rust#714.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rosterloh
rosterloh marked this pull request as ready for review September 23, 2026 19:13
@rosterloh

Copy link
Copy Markdown
Author

I ran the CI many more times on my fork and couldn't reproduce that CI failure. I think it might be a flake

MessageFieldInfo::size() reported every sequence field as
size_of::<TypeErasedSequence>() (data, size, capacity = 24 bytes). From
Lyrical on, rosidl_runtime_c appends the rosidl_buffer flags to primitive
and string sequences, which rosidl_runtime_rs 0.7 mirrors with
SequenceLayout::LayoutTail, making them 32 bytes. Message sequences are
not extended and stay 24.

The field slice handed to SequenceValue::new() was therefore 8 bytes
short, and reinterpret::<Sequence<T>>() tripped the check() assertion on
any primitive or string sequence read through DynamicMessage, e.g.
sensor_msgs/PointCloud2.data.

Size non-message sequences as Sequence<u8>, which carries the same tail
as every primitive and string element type (and no tail on earlier
distros, so nothing changes there). Add a test reading the int32 and
string defaults of test_msgs/UnboundedSequences; the existing test only
covered a message sequence, which is why CI on Lyrical did not catch it.

Refs ros2-rust#659

Assisted-by: Claude:claude-opus-5-5 [Claude Code]
@rosterloh
rosterloh force-pushed the fix/lyrical-sequence-field-size branch from 7d87703 to 1c77c5b Compare November 30, 2026 09:47
@rosterloh

Copy link
Copy Markdown
Author

@maspe36 @esteve I'd love to see this change make it into 0.9.0 so I can stop carrying my fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant