From 0217be4d5b5e9db768fd1b9edc6029645c81257c Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Fri, 22 Sep 2023 22:02:19 +0100 Subject: [PATCH] Fix GH-12232: FPM: segfault dynamically loading extension without opcache Also fixes incorrect assertion in ini init that php_dl is always temporary. Closes GH-12277 --- NEWS | 4 ++ Zend/zend_ini.c | 1 - sapi/fpm/fpm/fpm_php.c | 2 + .../tests/gh12232-php-value-extension.phpt | 51 +++++++++++++++++++ sapi/fpm/tests/tester.inc | 11 ++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 sapi/fpm/tests/gh12232-php-value-extension.phpt diff --git a/NEWS b/NEWS index 4c8dbb38b19..395cc3129f9 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ PHP NEWS - Fiber: . Fixed bug GH-11121 (ReflectionFiber segfault). (danog, trowski, bwoebi) +- FPM: + . Fixed bug GH-12232 (FPM: segfault dynamically loading extension without + opcache). (Jakub Zelenka) + - Opcache: . Added warning when JIT cannot be enabled. (danog) . Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 1b4710eb503..866e1b9c209 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -211,7 +211,6 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_ * lead to death. */ if (directives != EG(ini_directives)) { - ZEND_ASSERT(module_type == MODULE_TEMPORARY); directives = EG(ini_directives); } else { ZEND_ASSERT(module_type == MODULE_PERSISTENT); diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index 92b18966820..a9ad0433ba4 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -87,7 +87,9 @@ 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); php_dl(value, MODULE_PERSISTENT, &zv, 1); + zend_interned_strings_switch_storage(1); return Z_TYPE(zv) == IS_TRUE; } diff --git a/sapi/fpm/tests/gh12232-php-value-extension.phpt b/sapi/fpm/tests/gh12232-php-value-extension.phpt new file mode 100644 index 00000000000..207bd7a6779 --- /dev/null +++ b/sapi/fpm/tests/gh12232-php-value-extension.phpt @@ -0,0 +1,51 @@ +--TEST-- +FPM: gh12232 - loading shared ext in FPM config +--SKIPIF-- + +--FILE-- +start(); +$tester->expectLogStartNotices(); +$tester->request()->expectBody(['bool(true)', 'string(5) "hello"', 'string(4) "test"']); +$tester->request()->expectBody(['bool(true)', 'string(5) "hello"', 'string(4) "test"']); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + +