Skip to content

bug(opcache): the first redefine() does not take effect when opcache is active in the process (RedefineLeakPlateauTest child) #242

Closed

Description

@lisachenko

Summary (corrected — originally mis-attributed to PHP 8.5.9)

With opcache active in the process, tests/HotSwap/scripts/redefine-plateau.php fails at the very first warm-up cycle: after ReflectionFunction::redefine($body), calling plateau_function() still executes the original body (warm-up dispatch failed). Without opcache the script is green.

php8.4 -d ffi.enable=1 -d zend.assertions=1 -d assert.exception=1 -d display_errors=on \
  -d error_reporting=-1 -d memory_limit=512M \
  -d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.jit=off \
  tests/HotSwap/scripts/redefine-plateau.php
# STDERR: warm-up dispatch failed, exit 1
# same command with opcache.enable_cli=0: exit 0

Reproduced on PHP 8.4.19 and 8.4.24 (CI, PR #244's opcache-active runner job) and 8.5.9 — both lines, deterministic. Opcache in the child is the only variable.

Why it was first blamed on 8.5.9

The child spawn inherited opcache.enable_cli from php.ini. Ubuntu's PHP 8.5 package ships opcache.enable_cli=On while the 8.4 package ships Off, so a local master run failed and the local 8.4 run passed — which looked like a PHP-minor regression. PR #244's opcache-active CI job (which writes opcache.enable_cli=1 into php.ini, inherited by children) reproduced it on PHP 8.4.24 and exposed the real variable. Since #244 the child pins -d opcache.enable_cli=0 (with a TODO(#242) to unpin), so the leak measurement is hermetic; this issue tracks the underlying opcache bug.

Suspected area

Interesting contrast with the green OpcacheSupportMatrixTest leg, which redefines an opcache-shared function successfully: there the redefined function lives in a separate cached include, while plateau_function() is declared in the same cached file as the executing top level and the dispatch closures. Likely a stale resolution path (e.g. a run-time cache slot or call-site memoization inside the same shared script) that copy-out's bucket/name-cache repointing does not refresh. Needs a proper root-cause pass.

Found while enabling the opcache-active runner CI job (opcache epic). Companion opcache-in-child failure from the same runs: #243.

Activity

  1. changed the title [-]bug(master): RedefineLeakPlateauTest fails on PHP 8.5.9 — first redefine() does not take effect ("warm-up dispatch failed")[/-] [+]bug(opcache): the first redefine() does not take effect when opcache is active in the process (RedefineLeakPlateauTest child)[/+] on Aug 19, 2026
  2. added
    opcacheIssue is related to opcache integration. Either doesn't work well or behaves incorrect.
    on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopcacheIssue is related to opcache integration. Either doesn't work well or behaves incorrect.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions