Skip to content

Commit 01847d5

Browse files
authored
Fix SIGSEGV on ROS 2 Rolling caused by rosidl sequence ABI change (#1480)
ROS 2 Rolling merged ros2/rosidl#941 and ros2/rosidl#942 as part of the native buffer feature. The ROSIDL_RUNTIME_C__PRIMITIVE_SEQUENCE macro now emits two extra boolean fields (is_rosidl_buffer, owns_rosidl_buffer) in every primitive sequence struct, growing them from 24 to 32 bytes. Non-primitive sequences (e.g. Parameter__Sequence) are unchanged at 24 bytes. The rclnodejs code generator produces ref-struct-di definitions for these sequence types. Because the generated layout lacked the new fields, every message containing a primitive sequence had misaligned field offsets when serialized, causing Fast DDS to segfault in get_serialized_size_* during rcl_publish. Changes: 1. rosidl_gen/templates/message-template.js — Detect Rolling+ at generation time via DistroUtils.getDistroId() and compute needsRosidlBufferFields once per message. Conditionally emit is_rosidl_buffer and owns_rosidl_buffer in the generated sequence struct only for primitive-package types (Bool, Byte, Int8, …, Float64, String) on Rolling+. Generated files get clean, static struct definitions with no runtime require() or ternary. 2. .github/workflows/linux-x64-build-and-test.yml — Add rosidl_buffer_py and pybind11 to rosdep --skip-keys for the Rolling nightly install, since these new packages from the native buffer feature have unresolvable rosdep keys in the tarball context. Verified: Rolling: test-parameters (33), test-parameter-service (9), test-action-client (19) — all pass. Jazzy: test-parameters (33), test-parameter-service (9), test-action-client (18+1 pending) — all pass. Fix: #1481
1 parent fff7c0a commit 01847d5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/linux-x64-build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
# Install any remaining runtime dependencies using rosdep
8181
rosdep init || true
8282
rosdep update
83-
rosdep install --rosdistro rolling --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers python3-pyqt6.qtsvg"
83+
rosdep install --rosdistro rolling --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers python3-pyqt6.qtsvg rosidl_buffer_py pybind11"
8484
8585
- name: Install test-msgs and mrpt_msgs on Linux
8686
if: ${{ matrix.ros_distribution != 'rolling' }}

rosidl_gen/templates/message-template.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ function generateMessage(data) {
265265
const currentTypedArray = getTypedArrayName(spec.baseType);
266266
const currentTypedArrayElementType = getTypedArrayElementName(spec.baseType);
267267

268+
// ROS 2 Rolling (ros2/rosidl#941) added is_rosidl_buffer / owns_rosidl_buffer
269+
// to every primitive sequence struct. Emit the extra fields only for
270+
// primitive-package types on Rolling+.
271+
const DistroUtils = require('../../lib/distro.js');
272+
const needsRosidlBufferFields =
273+
isPrimitivePackage(spec.baseType) &&
274+
DistroUtils.getDistroId() >= DistroUtils.getDistroId('rolling');
275+
268276
// Track required modules
269277
let existedModules = [];
270278
function shouldRequire(baseType, fieldType) {
@@ -347,7 +355,13 @@ ${
347355
: ` data: ${refArrayType},`
348356
}
349357
size: ref.types.size_t,
350-
capacity: ref.types.size_t
358+
capacity: ref.types.size_t,
359+
${
360+
needsRosidlBufferFields
361+
? ` is_rosidl_buffer: ref.types.bool,
362+
owns_rosidl_buffer: ref.types.bool,`
363+
: ''
364+
}
351365
});
352366
353367
${generateWrapperClass()}

0 commit comments

Comments
 (0)