Skip to content

opcache_reset memory coprruption in ZTS under high concurrency (FrankenPHP) #18517

Description

@AlliBalliBaba

Description

opcache_reset will sometimes lead to memory corruptions in ZTS under high concurrency.

The bug was first raised in this issue in the FrankenPHP repo. The reproducer from that issue will cause a opcache_reset after a few thousand requests under load. I'm not sure why an opcache reset is forced, it could be caused by inline classes filling up the opcache.interned_strings_buffer.

The main issue seems to be though that if multiple threads are executing scripts simultaneously, it will sometimes lead to weird opcache issues and result in a zend_mm_heap corrupted when an opcache_reset is scheduled.

I also created a smaller reproducer that will force the issue with a dev version of PHP installed here:
https://github.com/AlliBalliBaba/zts-opcache-reset-reproducer

For reference: FrankenPHP uses the bookworm ZTS docker image and runs PHP with 1 process and multiple threads

PHP Version

PHP 8.4.5 (cli) (built: Mar 17 2025 23:15:56) (ZTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.5, Copyright (c), by Zend Technologies

Operating System

debian-bookworm (Docker)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions