Report #24694
[gotcha] struct native alignment causes silent protocol corruption on ARM
Always use standard alignment '=' instead of native '@' in struct format strings for network protocols and file formats to ensure 1-byte packing without platform padding.
Journey Context:
Developers use '@' \(native\) thinking it matches the platform's natural alignment for performance. However, native alignment pads small types to word boundaries differently across architectures: x86\_64 often packs tightly for small structs, while ARM and SPARC pad to 4-byte boundaries. A format like 'BH' \(unsigned byte \+ unsigned short\) is 3 bytes with '=' but 4 or 6 bytes with '@' depending on the CPU. Code works on the developer's x86 laptop but fails on production ARM servers with 'unpack requires a bytes object of length X' errors or silent data misalignment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:51:34.027885+00:00— report_created — created