Repository navigation
Conversation
PHP 8.5 adds attributes on constants. On php-wasm, OPcache corrupts these attributes when it writes the script to the file cache. The new test compiles a file that declares `#[Deprecated(message: 'bar')] const FOO`, then reads the attribute arguments again from the cached script. The test fails on the current PHP 8.5.10 binaries.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
On 32-bit builds, `ZEND_USE_ABS_CONST_ADDR` is set, so `RT_CONSTANT()` returns a pointer into `script->mem`, not into the serialization buffer. `zend_file_cache_serialize_op_array()` then rewrites the attributes of `ZEND_DECLARE_ATTRIBUTED_CONST` in the live script and writes a raw pointer to the file cache. The `php8.5.patch` hunk moves the literal pointer into the buffer before `SERIALIZE_ATTRIBUTES()`.
Rebuild the web and Node.js binaries, JSPI and Asyncify, for PHP 8.5 with the `php8.5.patch` fix. The build uses the 8.5.12 release tag, so `8_5_10/` becomes `8_5_12/` and the README examples follow.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes PHP 8.5 on php-wasm when OPcache stores a script that declares an attribute on a constant, such as
#[Deprecated] const FOO = 1;.symfony/polyfill-uuid1.43.0 declares such constants inbootstrap85.php.Why
I found this bug in Laravel Snippets. Its weekly "Refresh snippet sweep report" workflow runs Laravel snippets in Playground on PHP 8.5. The sweep now crashes with "Target crashed" when it loads
symfony/polyfill-uuid1.43.0. It passed on 2026-09-28 and failed on 2026-10-05, 2026-10-12 and 2026-10-19.This PR patches PHP 8.5 in
php8.5.patchuntil php-src fixes the bug. A php-src PR follows. When a PHP 8.5 release includes that fix, the hunk can go.Cause
zend_file_cache_serialize_op_array()inext/opcache/zend_file_cache.cserializes the attributes of eachZEND_DECLARE_ATTRIBUTED_CONSTthrough the literal in the nextZEND_OP_DATAopline. On 32-bit builds,ZEND_USE_ABS_CONST_ADDRis set, soRT_CONSTANT()returns a pointer intoscript->mem, not into the serialization buffer. The serializer then rewrites the live script and writes a raw pointer to the.binfile. wasm32 is a 32-bit target. The persist and unserialize code are correct. The bug is also on php-srcmaster, and no php-src issue exists yet.Commits
php-opcache.spec.tsthat reads the constant attribute from the compiled script and again from the file cache.php8.5.patch.lastReleasegoes from 8.5.10 to 8.5.12, and theweb/README.mdexamples follow.Testing
keeps constant attributes in the file cacheinphp-opcache.spec.ts:On Node 24,
WebAssembly.Suspendingexists without a flag, sotest-group-N-asyncifyalso loads the JSPI binary. The Asyncify columns come from a temporary spec that loads the Asyncify glue directly.Node JSPI groups 1 to 6 on this PR's binaries: all pass except 4 Imagick tests in group 2, on PHP 7.4 and 8.0. These tests download
image.jpgfromraw.githubusercontent.comand time out after 5 s. This PR does not touch those binaries.Also run:
npx nx test php-wasm-web(79 pass),npx nx test php-wasm-compile-extension(37 pass),npx nx lint php-wasm-node.php8.5.patchapplies to php-srcphp-8.5.10, and the new hunk applies alone to php-srcmaster.