Skip to content

Fixed GH-22216: don't warn in OnUpdateMemoryConsumption on ZTS thread init#22225

Open
dkkoma wants to merge 1 commit into
php:PHP-8.5from
dkkoma:fix-gh-22216-opcache-memcons-zts
Open

Fixed GH-22216: don't warn in OnUpdateMemoryConsumption on ZTS thread init#22225
dkkoma wants to merge 1 commit into
php:PHP-8.5from
dkkoma:fix-gh-22216-opcache-memcons-zts

Conversation

@dkkoma
Copy link
Copy Markdown

@dkkoma dkkoma commented Jun 4, 2026

Fixes GH-22216

Testing

Put this as /tmp/ztsrepro/repro_min.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

…ead init

The ZTS per-thread ini refresh runs on_modify at ZEND_INI_STAGE_STARTUP to
populate the new thread's globals; skip the accel_startup_ok guard there so
it is not treated as a post-startup change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant