Created attachment 904948 [details] emerge --info Building fontconfig with lto causes fonts to be oversized under some cases for sci-calculators/qalculate-gtk. See: https://github.com/Qalculate/qalculate-gtk/issues/550
Created attachment 904949 [details] Build log
Ha, I started to look at this and ran into bug 940927 which I'll need to fix first.
Could you give me some exact steps on what to do after opening qalculate-gtk? I can't reproduce it yet.
(In reply to Sam James from comment #3) > Could you give me some exact steps on what to do after opening > qalculate-gtk? I can't reproduce it yet. 1. In the top pane, input an expression that would be rendered using superscripts/subscripts (e.g. 2^2); 2. Observe in the pane below, the superscript/subscript is rendered at a much larger font that the base; 3. Emerge media-libs/fontconfig without lto and redo 1-2, observe that the superscript/subscript is rendered correctly. I can replicate this on 2 separate systems. Might only be an issue on wayland.
Thanks, it turns out I can reproduce with GCC 14 and not trunk. I will look more later.
It's not required, but if you can find any other testcases, that might be useful. Even better would be the testsuite of something using fontconfig failing. But again, not needed, it would just speed up some of the investigation later (as having to check graphically is a pain).
It becomes latent on trunk with r15-571-g1e0ae1f52741f7. Reverting it on trunk breaks it there too. I'll bisect for the break next, releases/gcc-13 is fine.
Introduced by r14-6536-gcd794c39610177 (sccp).
FcDefaultSubstitute gets a bogus value from FcPatternIterGetValues/FcValueCanonicalize, so in FcDefaultSubstitute, this trap fires: scale = 1.0; if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch) dpi = 75.0; if (FcPatternFindObjectIter (pattern, &iter, FC_PIXEL_SIZE_OBJECT)) { FcValueListPtr l = FcPatternIterGetValues (pattern, &iter); v = FcValueCanonicalize (&l->value); size = v.u.d; printf("size-before-scaling=%f\n", size); size = size / dpi * 72.0 / scale; printf("dpi=%f\n", dpi); printf("scale=%f\n", scale); printf("size=%f\n", size); } (void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT); if (fabs(size - 60.f) < 0.01) { __builtin_trap(); } Trying to separate it out more..
I think FC is wrong. This fixes it: ``` --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -253,7 +253,7 @@ typedef enum _FcValueBinding { typedef struct _FcPattern FcPattern; -typedef struct _FcPatternIter { +typedef struct __attribute__((may_alias)) _FcPatternIter { void *dummy1; void *dummy2; } FcPatternIter; ``` They pun betewen _FcPatternPrivateIter and _FcPatternIter: typedef struct _FcPatternPrivateIter { FcPatternElt *elt; int pos; } FcPatternPrivateIter;
Sent https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/333.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c9130151b56e3be1adc76e84df0e9dcd1a4bd3e3 commit c9130151b56e3be1adc76e84df0e9dcd1a4bd3e3 Author: Sam James <sam@gentoo.org> AuthorDate: 2024-10-08 16:05:00 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-10-08 16:05:47 +0000 media-libs/fontconfig: fix aliasing violation We had a report of GCC 14 with -O3 -flto causing wrong font sizes with fontconfig (showing up in qalculate-gtk). It turns out to be because _FcPatternIter and _FcPatternPrivateIter are punned between which violates strict-aliasing rules, which manifested in FcDefaultSubstitute getting a bogus value from FcValueCanonicalize for size. Mark the bad struct as may_alias to fix that. Closes: https://bugs.gentoo.org/940923 Signed-off-by: Sam James <sam@gentoo.org> .../files/fontconfig-2.15.0-aliasing.patch | 53 +++++ media-libs/fontconfig/fontconfig-2.15.0-r1.ebuild | 234 +++++++++++++++++++++ 2 files changed, 287 insertions(+)
Thank you for the report!
Thank you for your work in fixing this!