[php-src] PR #22225: Fixed GH-22216: don't warn in OnUpdateMemoryConsumption on ZTS thread init
| From: | dkkoma | Date: | Thu, 04 Jun 2026 08:11:27 +0000 |
| Subject: | [php-src] PR #22225: Fixed GH-22216: don't warn in OnUpdateMemoryConsumption on ZTS thread init | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36294@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22225
Author: dkkoma
Fixes GH-22216
## Testing
Put this as
/tmp/ztsrepro/repro_min.c
```c
#include <sapi/embed/php_embed.h>
#include <pthread.h>
static void *worker(void *arg)
{
ts_resource(0);
php_request_startup();
php_printf("[worker] ");
zend_eval_string("echo
opcache_get_configuration()['directives']['opcache.memory_consumption'],
PHP_EOL;", NULL, "w");
php_request_shutdown(NULL);
ts_free_thread();
return NULL;
}
int main(int argc, char **argv)
{
php_embed_init(argc, argv);
php_printf("[main] ");
zend_eval_string("echo
opcache_get_configuration()['directives']['opcache.memory_consumption'],
PHP_EOL;", NULL, "m");
pthread_t t;
pthread_create(&t, NULL, worker, NULL);
pthread_join(t, NULL);
php_embed_shutdown();
return 0;
}
```
Build php-src with --enable-zts --enable-embed, Run the following from the build root
```
cc /tmp/ztsrepro/repro_min.c -o /tmp/ztsrepro/repro_min -I. -Imain -IZend -ITSRM -Isapi/embed
-Iext/date/lib -D_GNU_SOURCE -DZTS -DZEND_SIGNALS -DNDEBUG -pthread -Llibs -lphp -Wl,-rpath,libs
```
### ini
```
echo 'opcache.log_verbosity_level=2' > /tmp/ztsrepro/opcache.ini
```
### before
```
$ PHPRC=/tmp/ztsrepro/opcache.ini /tmp/ztsrepro/repro_min
[main] 134217728
Thu Jun 4 16:35:49 2026 (6129397760): Warning opcache.memory_consumption cannot be changed when
OPcache is already set up.
[worker] 0
```
### after
```
$ PHPRC=/tmp/ztsrepro/opcache.ini /tmp/ztsrepro/repro_min
[main] 134217728
[worker] 134217728
```