1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Disable ZEND_RC_MOD_CHECK() while loading shared extension in FPM

This fixes a ZEND_RC_MOD_CHECK() assertion failure when building with
"-DZEND_RC_DEBUG=1 --enable-debug --enable-zts". php_dl() is called after
startup, and manipulates the refcount of persistent strings, which is not
allowed at this point of the lifecycle.

The dl() function disables the ZEND_RC_MOD_CHECK() assertion before calling
php_dl(). This change applies the same workaround in FPM.

Closes GH-18075
This commit is contained in:
Arnaud Le Blanc
2025-03-15 12:18:08 +01:00
parent bd7d3c38ad
commit c531f3d79b

View File

@@ -93,7 +93,21 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
if (!strcmp(name, "extension") && *value) {
zval zv;
zend_interned_strings_switch_storage(0);
#if ZEND_RC_DEBUG
bool orig_rc_debug = zend_rc_debug;
/* Loading extensions after php_module_startup() breaks some invariants.
* For instance, it will update the refcount of persistent strings,
* which is normally not allowed at this stage. */
zend_rc_debug = false;
#endif
php_dl(value, MODULE_PERSISTENT, &zv, 1);
#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
zend_interned_strings_switch_storage(1);
return Z_TYPE(zv) == IS_TRUE ? FPM_PHP_INI_EXTENSION_LOADED : FPM_PHP_INI_EXTENSION_FAILED;
}