You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OPcache: file cache loses attributes on constants on 32-bit builds #24745
I reproduced it with the i386/php:8.5-cli Docker image. The same image gives the expected output without OPcache, and with the file cache for a constant without an attribute. php:8.5-cli on amd64 gives the expected output with the file cache.
if (opline->opcode==ZEND_OP_DATA&& (opline-1)->opcode==ZEND_DECLARE_ATTRIBUTED_CONST
) {
zval*literal=RT_CONSTANT(opline, opline->op1);
SERIALIZE_ATTRIBUTES(Z_PTR_P(literal));
}
opline points into the serialization buffer. With ZEND_USE_ABS_CONST_ADDR (32-bit builds), RT_CONSTANT() returns opline->op1.zv. That pointer is not serialized yet, so it still points to the literal in script->mem, not to its copy in buf. SERIALIZE_ATTRIBUTES() therefore rewrites the attributes pointer of the live script and leaves a raw pointer in the buffer:
the current request loses the attributes of the constant;
the .bin file stores an invalid pointer, which every later request loads.
On 64-bit builds, RT_CONSTANT() is relative to opline, so it already resolves into buf. zend_file_cache_unserialize_op_array() is correct, because it reads the literal after it unserializes op1.zv.
A possible fix, with the same pattern as the GH-17733 code for ZEND_INIT_FCALL a few lines below:
PHP 8.5.12 (cli) (built: Oct 21 2026 15:55:33) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.12, Copyright (c) Zend Technologies
with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies
Operating System
Debian, i386 (i386/php:8.5-cli Docker image under qemu on macOS arm64)
Activity
mho22 commentedon Oct 26, 2026
The same crash happens on
arm32v7/php:8.5-cli. On an i386 build ofphp-8.5.12from source, the fix above makes both runs print the expected output.ndossche commentedon Oct 26, 2026
Might be fixed on master by #24392
Fix phpGH-24745: File cache loses attributes on constants on 32-bit b…
Merge branch 'PHP-8.5' into PHP-8.6
Merge branch 'PHP-8.6'
[ php-wasm ] Keep constant attributes in the PHP 8.5 OPcache file cac…