[php-src] Issue #25296: opcache.file_cache: segfault or wrong function for functions loaded with dl()

From: Date: Sat, 07 Nov 2026 19:25:34 +0000
Subject: [php-src] Issue #25296: opcache.file_cache: segfault or wrong function for functions loaded with dl()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-254058@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25296 Author: Enfiladeguide ### Description *Quoted text written with an LLM and checked by a human developer.* > A script in the file cache can crash or call the wrong function if it calls a function loaded > with dl(), and that function has a different position in the > function table on a later run. > > d6541df63 (GH-24664) removed the reset of the ZEND_INIT_FCALL > offset from zend_file_cache.c. The old comment said the reset could > go once system ID validation was in place. The system ID is finalized at startup, so it does not > cover functions added later by dl(). main.php: ```php <?php if (isset($argv[1])) { function a() {} function b() {} } dl('dl_test'); include __DIR__ . '/call.php'; ``` call.php: ```php <?php var_dump(dl_test_test2()); ``` With dl_test built as a shared extension: ```sh PHP="php -d opcache.enable_cli=1 -d opcache.file_cache=/tmp/fc -d opcache.file_cache_only=1 -d opcache.file_update_protection=0" $PHP main.php x $PHP main.php ``` Resulted in this output: ``` string(11) "Hello World" Segmentation fault ``` But I expected this output instead: ``` string(11) "Hello World" string(11) "Hello World" ``` With only function a() {}, the second run calls a different function: ``` Fatal error: Uncaught ArgumentCountError: dl_test_frameless() expects exactly 1 argument, 0 given ``` Tested on debug and release builds of PHP-8.4 at 3ace94211. An earlier build at 2f6fd1167, without d6541df63, prints the expected output. The reset is also gone from the sources of php-8.4.28RC1, php-8.5.13RC1 and php-8.6.0RC5, which I did not build. Related: GH-24661 ### PHP Version ``` PHP 8.4.28-dev (3ace94211) ``` ### Operating System Ubuntu 26.04

« previous php.bugs (#254058) next »