Open wezm opened 2 weeks ago
I suspect this is something I've seen before and relates to compiler optimization. If you're in a position to you might be able to confirm this by building e.g. tx
and trying that out. If you have the build tools installed tis might work (from the top directory of the sources in the develop
branch of this repo):
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug
cd build
ninja
The compiled executables would then be in build/bin
.
Unfortunately when I saw this I looked at the code and didn't find any self-evident undefined behavior so it's not clear what the fix would be.
You're right, a debug build generates the right output:
Interestingly a Release build built with clang
(18.1.8) is also fine. Release build built with gcc
(14.2.1) and -fsanitize=undefined
yields no sanitizer errors but produces the bad output.
Additionally building with gcc
(13.3.0) the output is right in a release build... maybe it's a gcc issue?
CC=gcc-13 CXX=g++-13 cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release
Well, on the one hand blaming one's compiler is almost always a recipe for getting egg on one's face. But on the other hand it sure seems like almost everything is pointing in that direction. The test suite doesn't pass when this problem gets compiled in so we have a pretty good idea of when it happens, and so far I've only seen it on Arch (and therefore on the bleeding edge of gcc releases).
When I first saw this and looked into the code I tentatively decided it was probably a compiler problem (because there really didn't seem to be anything in the ballpark of UB) that would quickly go away because someone would run into some form of it in a more flashy context and it would quickly get fixed. But it's been months now, so I guess we need to do something about it. I guess try to make a small repeatable case.
Still, very weird to run into this in this way. It makes me wonder what I'm missing.
Would you be willing to add a note to AUR pointing to this issue and suggesting a different build strategy for the time being? (Presumably either debug or a different compiler ...)
Might be worth seeing if -fno-strict-aliasing
eliminates the problem.
Would you be willing to add a note to AUR pointing to this issue and suggesting a different build strategy for the time being? (Presumably either debug or a different compiler ...)
No problem, done: https://aur.archlinux.org/packages/afdko#comment-998167
Might be worth seeing if
-fno-strict-aliasing
eliminates the problem.
A build as follows still produced the incorrect output:
CFLAGS=-fno-strict-aliasing CXXFLAGS=-fno-strict-aliasing cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release
Thank you for that note and the check! That's interesting -- so it's not the most obvious example from the gcc issue queue. I guess isolating a reproducible case is the way to go.
Here's a small reproducible case. reprocase.zip
New GCC bugzilla accounts are restricted right now so I'm waiting on an email request.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117546 . Looks like the cause of the problem has already been fixed but the fix is still percolating outward.
Thanks for investigating!
This started happening in the 4.0 release I think. It was previously fine, now the outlines of the glyphs in many fonts are incorrect. E.g.
Info
Host: Arch Linux x86_64 afdko: 4.0.2 built from source via AUR
example.pdf