fix: add align(8) to rcl_context_s and rmw_context_s for ARM32#614
Open
roadmore wants to merge 1 commit intoros2-rust:mainfrom
Open
fix: add align(8) to rcl_context_s and rmw_context_s for ARM32#614roadmore wants to merge 1 commit intoros2-rust:mainfrom
roadmore wants to merge 1 commit intoros2-rust:mainfrom
Conversation
On ARM32 Linux (kernel 4.19), rcl_context_s.instance_id_storage is declared as [u8; 8] which gives the struct alignment of 4 instead of 8. When librcl.so accesses this field with a Thumb-2 LDRD instruction from a 4-byte-aligned address, it triggers BUS_ADRALN (SIGBUS) because the kernel alignment fixup handler cannot handle Thumb-2 LDRD. In C, instance_id_storage is atomic_uint_least64_t (align=8), so the struct naturally gets 8-byte alignment. The Rust binding must match. Similarly, rmw_context_s has instance_id: u64 which already implies align(8) in repr(C), but adding explicit align(8) for safety.
Collaborator
|
@roadmore these bindings are automatically generated by rust-bindgen, we don't aim to maintain them ourselves, they are just there for convenience. Can you give us more details of the platform you're running ros2-rust on? 4.19.87 is a rather old kernel, which none of the platforms that ROS currently support ship with. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#[repr(C, align(8))]torcl_context_sandrmw_context_sin the Humble bindings to fixSIGBUS (BUS_ADRALN)on ARM32 Linux.Problem
On ARM32 Linux (kernel 4.19),
rcl_context_s.instance_id_storageis declared as[u8; 8](alignment = 1), which gives the struct an alignment of 4 (from pointer fields). In C, this field isatomic_uint_least64_t(alignment = 8), so the C struct naturally gets 8-byte alignment.When
librcl.soaccesses theinstance_id_storagefield using a Thumb-2LDRDinstruction from a 4-byte-aligned (but not 8-byte-aligned) address, the kernel's alignment fixup handler cannot handle Thumb-2 LDRD, resulting inSIGBUS.Fix
Add explicit
align(8)to match the C struct's alignment. This is a no-op on 64-bit platforms (pointer alignment is already 8), and only affects 32-bit platforms where it corrects the struct alignment from 4 to 8.Test plan
SIGBUSresolved🤖 Generated with Claude Code