Bug #65915 [NEW]: Inconsistent results with require return value
From: arjen at react dot com
Operating system: Linux
PHP version: 5.5.4
Package: opcache
Bug Type: Bug
Bug description:Inconsistent results with require return value
Description:
------------
opcache seems to 'cache' the return value of a require statement, even
if opcache_invalidate or opcache_reset is called. A test script which
returns a closure is written to disk, required and result method is
called. File is overwritten and called again. Output should differ, but
is the same. A helper var written to the same file IS correctly
updated.
Result is wrong most of the times.
php -d zend_extension=/usr/lib/php/modules/opcache.so -d
opcache.enabled=1 -d opcache.enable_cli=1 -d
opcache.optimization_level=0xffffffff public_html/php/opcache.php
opcache.optimization_level=0x00000000 also fails.
Test script:
---------------
<?php
$tmp = tempnam(sys_get_temp_dir(), 'test');
file_put_contents($tmp, '<?php $s = ' . microtime(true) . ';return
function(){ return "a";};');
$f = require $tmp;
var_dump($s, $f());
sleep(2);
file_put_contents($tmp, '<?php $s = ' . microtime(true) . ';return
function(){ return "ab";};');
opcache_invalidate($tmp, true);
$f = require $tmp;
var_dump($s, $f());
unset($f);
opcache_reset();
$f = require $tmp;
var_dump($s, $f());
Expected result:
----------------
double(1381930079.4517)
string(1) "a"
double(1381930079.452)
string(2) "ab"
double(1381930079.452)
string(2) "ab"
Actual result:
--------------
double(1381930079.4517)
string(1) "a"
double(1381930079.452)
string(1) "a"
double(1381930079.452)
string(1) "a"
--
Edit bug report at https://bugs.php.net/bug.php?id=65915&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65915&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65915&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65915&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65915&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65915&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65915&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65915&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65915&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65915&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65915&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65915&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65915&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65915&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65915&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65915&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65915&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65915&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65915&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65915&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65915&r=mysqlcfg
Thread (8 messages)
- arjen at react dot com