Bug 2164233

Summary: FcCacheFini: Assertion `fcCacheChains[i] == NULL' failed.
Product: [Fedora] Fedora Reporter: Byoungchan Lee <byoungchan.lee>
Component: openttdAssignee: Felix Kaechele <felix>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 37CC: ajax, felix, fonts-bugs, gnome-sig, i18n-bugs, mclasen, pnemade, rstrode, sandmann, tagoh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openttd-13.1-1.fc38 openttd-13.1-1.fc37 openttd-13.1-1.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-04-22 00:46:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Crash log
none
crash_gdb.log none

Description Byoungchan Lee 2023-01-24 20:44:55 UTC
Description of problem:
When I try to run openttd, fontconfig crashes due to an assertion.

https://github.com/freedesktop/fontconfig/blob/2.14.1/src/fccache.c#L808

Version-Release number of selected component (if applicable):

$ rpm -qa | grep fontconfig
fontconfig-2.14.1-2.fc37.x86_64
fontconfig-2.14.1-2.fc37.i686
fontconfig-devel-2.14.1-2.fc37.x86_64
fontconfig-debugsource-2.14.1-2.fc37.x86_64

$ rpm -qa | grep openttd
openttd-opengfx-7.1-3.fc37.noarch
openttd-12.2-4.fc37.x86_64


How reproducible:
Run openttd


Steps to Reproduce:
1.
2.
3.

Actual results:

Crash

Expected results:

Game runs.

Additional info:

I'm not sure why assertions are enabled in fontconfig.

Comment 1 Byoungchan Lee 2023-01-24 20:45:37 UTC
Created attachment 1940295 [details]
Crash log

Comment 2 Akira TAGOH 2023-01-25 01:52:22 UTC
Well, this is basically a memory-leak report in application. if it is 100% reproducible even after re-creating caches with fc-cache -f, it is a bug in openttd.

Comment 3 Akira TAGOH 2023-01-25 01:54:22 UTC
Try to run openttd with FC_DEBUG=16. you'll see more details then.

Comment 4 Byoungchan Lee 2023-01-25 12:36:29 UTC
I already uploaded the log with `FC_DEBUG=16`. It is included in the attached file (zip file). Anyway, I'll check out why the memory leak happened.

Comment 5 Akira TAGOH 2023-01-25 13:22:20 UTC
What I can say is that 12 of reference count is too much. there should definitely be a memory leak in openttd, possibly not freed FcPattern which have a reference to those caches. check around code where use FcFontList or FcFontMatch in openttd.

Comment 6 Byoungchan Lee 2023-01-25 13:45:03 UTC
Created attachment 1940410 [details]
crash_gdb.log

Comment 7 Byoungchan Lee 2023-01-25 13:46:52 UTC
If I modify openttd to force the use of X11, it works fine.

```
SDL_SetHint(SDL_HINT_VIDEODRIVER, "x11");
```

It also works fine when I remove FcFini function calls from openttd.

I ran gdb to understand what happened with the fontconfig call, and I attached the result. When SDL2 uses Wayland, Pango is also used, which uses fontconfig. By the way, I discovered that Pango calls FcInit but not FcFini. Also, FcInit is called from a thread other than the main thread, whereas openttd proceeds with all fontconfig-related function call on the main thread.

Comment 8 Akira TAGOH 2023-01-25 14:08:04 UTC
I don't think gdb helps you to find out memory leaks. what you need to run with openttd should be valgrind.

Comment 9 Byoungchan Lee 2023-01-25 14:27:58 UTC
What I want to say is that Pango does not call FcFini, and openttd does not crash if Pango (and Wayland) is not used. If you think this is a Pango or openttd bug, please change the component.

Comment 10 Akira TAGOH 2023-01-26 03:24:10 UTC
Moving to openttd so far.

Comment 11 Felix Kaechele 2023-02-06 16:41:39 UTC
I've just pushed the update to 13.0. Can you check if this still happens?

https://bodhi.fedoraproject.org/updates/FEDORA-2023-33d7773514

Comment 12 Fedora Update System 2023-04-13 01:22:46 UTC
FEDORA-2023-1c2ee094a2 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-1c2ee094a2

Comment 13 Fedora Update System 2023-04-13 01:22:55 UTC
FEDORA-2023-21b190cdf1 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-21b190cdf1

Comment 14 Fedora Update System 2023-04-13 01:23:04 UTC
FEDORA-2023-fe8f70bcc8 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fe8f70bcc8

Comment 15 Fedora Update System 2023-04-14 02:41:18 UTC
FEDORA-2023-1c2ee094a2 has been pushed to the Fedora 38 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-1c2ee094a2

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2023-04-14 02:45:56 UTC
FEDORA-2023-21b190cdf1 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-21b190cdf1`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-21b190cdf1

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 17 Fedora Update System 2023-04-14 02:48:03 UTC
FEDORA-2023-fe8f70bcc8 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-fe8f70bcc8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-fe8f70bcc8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2023-04-22 00:46:50 UTC
FEDORA-2023-1c2ee094a2 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Fedora Update System 2023-04-22 00:54:09 UTC
FEDORA-2023-21b190cdf1 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 20 Fedora Update System 2023-04-22 01:11:38 UTC
FEDORA-2023-fe8f70bcc8 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.