diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 3e8bdea9c7a6b..e0f8cda2298e8 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4462,6 +4462,12 @@ static zend_result accel_preload(const char *config, bool in_child) /* Release stored values to avoid dangling pointers */ zend_shutdown_executor_values(/* fast_shutdown */ false); + /* On ZTS we execute `executor_globals_ctor` which reset the freelist and p5s pointers, while on NTS we don't. + * We have to clean up the memory before the actual request takes place to avoid a memory leak. */ +#ifdef ZTS + zend_shutdown_strtod(); +#endif + /* We don't want to preload constants. * Check that zend_shutdown_executor_values() also destroys constants. */ ZEND_ASSERT(zend_hash_num_elements(EG(zend_constants)) == EG(persistent_constants_count)); diff --git a/ext/opcache/tests/gh16577.inc b/ext/opcache/tests/gh16577.inc new file mode 100644 index 0000000000000..f016d61281784 --- /dev/null +++ b/ext/opcache/tests/gh16577.inc @@ -0,0 +1,2 @@ + +--FILE-- + +--EXPECT-- +float(1.5) +Done