Bug 272091 - graphics/gd: add option to change timing of gdFontCacheMutex setup and shutdown
Summary: graphics/gd: add option to change timing of gdFontCacheMutex setup and shutdown
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dirk Meyer
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2023-06-20 10:09 UTC by Tatsuki Makino
Modified: 2023-07-02 05:20 UTC (History)
1 user (show)

See Also:
dinoex: maintainer-feedback+


Attachments
experimental patch for graphics/gd (5.14 KB, patch)
2023-06-20 10:09 UTC, Tatsuki Makino
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tatsuki Makino 2023-06-20 10:09:04 UTC
Created attachment 242887 [details]
experimental patch for graphics/gd

Life cycle of the gdFontCacheMutex related to fontCache seems to be wrong and fontCache may be used when it is NULL.
This problem seems to be resolved in the bundled version of PHP.
It seems to me that a bundled version should be used for php, but I guess a combination of mod_php (e.g. mod_php81+php81-gd) and mod_perl (e.g. ap24-mod_perl2+p5-GD), etc. would cause conflicts in the symbol table. but I don't know :)
So I have prepared a patch that I think will make this equivalent to the bundled version of php.
The option is THREADS for now, but I think the meaning is different :)
Comment 1 Mina Galić freebsd_triage 2023-06-21 08:40:55 UTC
I still don't understand why it's necessary to bring all that code into a single… application server. are these various applications dependent on each other's state in that single server? 

if not, you should either split this into:

- two application servers (one for mod_perl and one for mod_php) and proxy in front
- or, just a proxy, which uses mod_proxy_fcgi and fpm for php, and one of the several FCGI frameworks for perl

even if we do fix this, there's no telling what's going to break next with this much code in one server
Comment 2 Dirk Meyer freebsd_committer freebsd_triage 2023-06-23 07:44:19 UTC
I will look into this.
Comment 3 Tatsuki Makino 2023-06-23 09:09:12 UTC
(In reply to Mina Galić from comment #1)

It just so happens that Apache httpd used thread MPM (worker,event) + mod_php is the one that can keep calling gdImageStringFTEx enough to cause problems, and this could happen in any multi-threaded program that uses it.

(In reply to Dirk Meyer from comment #2)

In my environment, I am experimenting with this as is for now, but please look at it up to the possibility of rewriting everything as the case may be :)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-07-01 15:10:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7311c841f51fa73d3f380e2f4b270044e94a3b91

commit 7311c841f51fa73d3f380e2f4b270044e94a3b91
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2023-07-01 15:10:04 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2023-07-01 15:10:04 +0000

    graphics/gd: add option to change timing of gdFontCacheMutex setup and shutdown

    PR: 272091

 graphics/gd/Makefile                        |   4 +-
 graphics/gd/files/extra-patch-threads (new) | 154 ++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+), 1 deletion(-)