GNOME Bugzilla – Bug 674773
division by 0 due to unhandled alignment check failure at configure time
Last modified: 2012-04-25 13:21:57 UTC
Commit 839957f275875b6f8fd033d67379bce0fde1c58f, followed by 8f8fc836709cff58bd666b87937542088cfc19db added the following to configure.ac AC_CHECK_ALIGNOF([guint32], [AC_INCLUDES_DEFAULT typedef unsigned $gint32 guint32;]) AC_CHECK_ALIGNOF([guint64], [AC_INCLUDES_DEFAULT typedef unsigned $gint64 guint64;]) AC_CHECK_ALIGNOF([unsigned long]) Unfortunately, the way in which the AC_CHECK_ALIGNOF macro calculates alignment is very fragile and generally does not work during crosscompilation. There are multiple problems with the macro implementation, but the one that is of consequence for glib is that the failure can result in ALIGNOF_<type> being defined to 0, which then leads to a happy division by 0 in msort_r (gqsort.c). So so some kind of a sanity check is needed here, preferably generating a configure-time error. (BTW, it is not necessary to 'make this work' for crosscompilation; the way the autoconf crosscompilation limitations are usually addressed is to feed autoconf a precomputed cache of various autoconf variables, so all is needed here is to make it fail, so that it is obvious that these values are missing from the cache.)
*** This bug has been marked as a duplicate of bug 674483 ***