Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlliBalliBaba opened this issue May 7, 2025 · 3 comments

Comments

@AlliBalliBaba
Copy link

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)

@nielsdos
Copy link
Member

nielsdos commented May 7, 2025

Duplicate of #14471 (and likely also #8739)

@AlliBalliBaba
Copy link
Author

@nielsdos is it possible to disable the interned_strings_buffer? I'm still looking into why it's filling up to the point of forcing a reset, but it only seems to happen in that specific reproducer and only under concurrency.

@AlliBalliBaba
Copy link
Author

Nvm I realized it can be disabled by just setting opcache.interned_strings_buffer=0

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

No branches or pull requests

2 participants