ext/enchant: abort when PHP starts twice in a process with libenchant 2.8
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 57/100
Piste de recherche
Start with the Enchant extension's MINIT function, referenced in the issue, and trace how its module handle is unloaded during PHP shutdown and startup. Reproduce the two-start embed case with libenchant 2.8; done means the process prints “ok” twice without GLib errors or aborting. The issue suggests retaining the extension handle, but that approach needs review.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
The following code, built against the embed SAPI and run with extension=enchant in php.ini:
#include <sapi/embed/php_embed.h>
int main(int argc, char **argv)
{
for (int i = 0; i < 2; i++) {
PHP_EMBED_START_BLOCK(argc, argv)
zend_eval_string("enchant_broker_init(); echo \"ok\\n\";", NULL, "repro");
PHP_EMBED_END_BLOCK()
}
return 0;
}
Resulted in this output, and the process aborts:
ok
(process:164148): GLib-GObject-CRITICAL **: 09:58:25.468: cannot register existing type 'EnchantProvider'
(process:164148): GLib-CRITICAL **: 09:58:25.468: g_once_init_leave: assertion 'result != 0' failed
(process:164148): GLib-GObject-ERROR **: 09:58:25.468: cannot create new instance of invalid (non-instantiatable) type '<invalid>'
But I expected this output instead:
ok
ok
libenchant is written in Vala since 2.7.0 and registers GLib types the first time a broker is created. php_module_shutdown() unloads enchant.so and libenchant with it, but GLib is linked with -z nodelete and keeps these types. The next php_module_startup() loads libenchant again, which registers them a second time: GLib refuses, and creating the broker aborts.
An embedder that restarts PHP in its process hits this. I found it with FrankenPHP, which does so to restart its workers or to reload its configuration (php/frankenphp#2834): on Ubuntu 26.04, the first use of enchant after a restart kills the server.
With ZEND_DONT_UNLOAD_MODULES=1 in the environment, the program prints ok twice. The extension could keep itself loaded by dropping its handle, as OPcache does for its own, which gives the same result here:
PHP_MINIT_FUNCTION(enchant)
{
+ /* GLib keeps the types libenchant registers: the library can't be loaded twice */
+ enchant_module_entry.handle = NULL;
+
enchant_broker_ce = register_class_EnchantBroker();
PHP Version
PHP 8.5.12 (cli) (built: Nov 12 2026 09:52:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.12, Copyright (c) Zend Technologies
with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies
Same on master (bc2d2fcc7cb).
Operating System
Ubuntu 26.04, with libenchant 2.8.2 and GLib 2.88.0
- Langage dominant
- C
- Étoiles
- 41.8k
- Forks
- 8.6k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 125
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/php-src
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)OuverteExtension: openssl Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
php/php-src#25402 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
php/php-src#25397 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
SNMP accepts malformed remote portsPeut-être pris @somethingwithproof l’a pris il y a 21 jours. Ouverte
Difficulté 2/5 Une demi-journée Accessibilité débutants 62/100
php/php-src#25137 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de php/php-src
Issues similaires
-
interpreter-core type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
ImageMagick/ImageMagick6#490 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
camera-2018/hdu-cs-wiki#647 ·
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
AcademySoftwareFoundation/openexr#2884 ·
Les mainteneurs répondent en général sous 1 jour