[php-src] Issue #22782: Const expr FCC crashes under preloading

From: Date: Fri, 17 Jul 2026 12:01:37 +0000
Subject: [php-src] Issue #22782: Const expr FCC crashes under preloading
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252443@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22782 Author: arnaud-lb ### Description The following code: ``` php // preload.inc #[Attribute] class A { function __construct(public mixed $fn) {} } #[A(strlen(...))] class C { const CC = strlen(...); #[A(strlen(...))] function f($arg = strlen(...)) { return $arg; } } const CC = strlen(...); ``` ``` php // preload.php echo "# Class const\n"; var_dump((C::CC)('hello')); echo "# Class attr\n"; var_dump((new ReflectionClass(C::class)->getAttributes(A::class)[0]->newInstance()->fn)('hello')); echo "# Method attr\n"; var_dump((new ReflectionMethod(C::class, 'f')->getAttributes(A::class)[0]->newInstance()->fn)('hello')); echo "# Method default value\n"; var_dump((new C()->f())('hello')); ``` When executed with ``` $ php -d opcache.enable_cli=1 -d opcache.preload=preload.inc preload.php ``` Resulted in two issues: * Preloading evaluates class constants during compilation, but FCCs evaluate to objects, which can't be persisted * zend_fcc_ast->fptr is allocated with ZEND_MAP_PTR_NEW during compilation, which results in map ptr collisions later ### PHP Version ```plain PHP 8.5 ``` ### Operating System _No response_

« previous php.bugs (#252443) next »