On Thu, 2020-05-14 at 18:48 +0200, Christian Weisgerber wrote: > Martijn van Duren: > > > So msgfmt crashes an insane amount of times on alpha (rough guess is 75% > > of the time) which is a pain when building other packages. > > That is odd. Why does this only happen on alpha? When did it start > happening on alpha? Years ago I had an alpha and this is a "new" > problem.
Don't know, since this system is running less then a week. >From gettext-tools/src/Changelog.1 the freea idiom was added in 2007. > > > tl;dr: should we disable alloca in gettext and what's the best way to > > do this if so? > > I'm reluctant to work around a problem that isn't properly understood. I understand, but considering it's a configure time tested feature that enables a function that has a big fat warning label on it I thought I'd save myself the time. :-) So I did some additional testing and the math appears to check out. >From what I can gather it allocates some additional space and moves the pointer to the next sa_alignment_max so the first sa_alignment_max bits are cleared for alloca or the msb can be set for mmalloca, which determines whether or not it needs to be freed. I fully disassembled the gettext-tools/gnulib-lib/xmalloca.h xmalloca function (which allocates the memory that crashes) and put a printf in between steps. This doesn't result in a crash and matches the alignment math done by gettext. Doing a printf after where the memory was allocated by the original macro it turns out that alloca'd memory which was aligned on the bit required for malloc-checking was not shifting. This hinted at an optimization error. After this I started playing with the -O flag and when tuning -O back to -O0 the code also works. In other words this looks like an optimization bug/eagerness in the gcc; gcc-8 also crashes with default -O2. > The best way is to override the configure check by setting the > corresponding variable. Something like ac_cv_func_alloca_works=no > in CONFIGURE_ENV. > This works, so I see two options: - Move away from this dangerous idiom and set ac_cv_func_alloca_works=no either for alpha or in general. - Set CFLAGS to -O0 for alpha. Either one works for me.