Skip to content

Commit c531f3d

Browse files
committed
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 phpGH-18075
1 parent bd7d3c3 commit c531f3d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sapi/fpm/fpm/fpm_php.c

+14
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,21 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
9393
if (!strcmp(name, "extension") && *value) {
9494
zval zv;
9595
zend_interned_strings_switch_storage(0);
96+
97+
#if ZEND_RC_DEBUG
98+
bool orig_rc_debug = zend_rc_debug;
99+
/* Loading extensions after php_module_startup() breaks some invariants.
100+
* For instance, it will update the refcount of persistent strings,
101+
* which is normally not allowed at this stage. */
102+
zend_rc_debug = false;
103+
#endif
104+
96105
php_dl(value, MODULE_PERSISTENT, &zv, 1);
106+
107+
#if ZEND_RC_DEBUG
108+
zend_rc_debug = orig_rc_debug;
109+
#endif
110+
97111
zend_interned_strings_switch_storage(1);
98112
return Z_TYPE(zv) == IS_TRUE ? FPM_PHP_INI_EXTENSION_LOADED : FPM_PHP_INI_EXTENSION_FAILED;
99113
}

0 commit comments

Comments
 (0)