GNOME Bugzilla – Bug 661839
Invalid alignment assumptions
Last modified: 2015-02-07 16:53:50 UTC
The current source has invalid assumptions about structure alignment that break on m68k because 32-bit quantities require only 16-bit alignment there. A fix for this by introducing explicit structure padding to make the binary representation generated by the compiler match the text of the specification exactly will be attached. (The fix was written by Andreas Schwab, thanks!)
Created attachment 199063 [details] [review] patch to fix this issue (builds successfully on m68k now)
Actually, all parts of “the stack” should be checked for such assumptions; basically, everywhere a “smaller” value (here: gint8, guint16) is followed by a “bigger” value (here: SimpleTypeBlob and guint32, respectively) or a type smaller than 4 octets is used at the end of a structure (Header). Otherwise you _will_ get binary incompatibilities which are… not nice. (Isn’t there a -Wpadding option to GCC?)
Created attachment 201741 [details] [review] patch to fix the problem, updated 1 time
I can confirm that “gobject-introspection (1.31.0-2) unstable” (including its upstream portion) still exhibits the problem. Please apply the patch I supplied. I’ve rebased it against 1.31.0 now and am currently building it and talking to the Debian maintainer about inclusion, too.
OK to push this now?
Initially I was a little worried that this will change the typelib binary format on some platforms, but upon inspection it looks safe.
commit 9e56835f5ebb601aa0cb22130555a8a4ef15b11b Author: Thorsten Glaser <tg@debian.org> Date: Wed Feb 8 09:02:37 2012 -0500 typelib: Fix invalid alignment assumptions The current source has invalid assumptions about structure alignment that break on platforms like m68k where 32-bit integers are aligned to 16-bit only. Fix this by introducing explicit structure padding for 32-bit quantities following odd numbers of 16-bit quantities and structure trail padding, to make the binary representation generated by the compiler match the text of the specification exactly. https://bugzilla.gnome.org/show_bug.cgi?id=661839
(In reply to comment #6) > Initially I was a little worried that this will change the typelib binary > format on some platforms Well yes, it changed it on m68k to match that of all other platforms ;-) In fact, the changes take the previously implicit padding and make it explicit and any platform that would be affected by it would not previously have worked at all. Thanks!
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]