Bug #65915 [Com]: Inconsistent results with require return value

From: Date: Tue, 19 Nov 2013 17:00:45 +0000
Subject: Bug #65915 [Com]: Inconsistent results with require return value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182834@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65915&edit=1

 ID:                 65915
 Comment by:         Terry at ellisons dot org dot uk
 Reported by:        arjen at react dot com
 Summary:            Inconsistent results with require return value
 Status:             Assigned
 Type:               Bug
 Package:            opcache
 Operating System:   Linux
 PHP Version:        5.5.4
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

This is quite a subtle problem, that I will document and post a fix back here.


Previous Comments:
------------------------------------------------------------------------
[2013-11-04 14:42:29] zoeslam at gmail dot com

This bug is likely related to https://bugs.php.net/bug.php?id=65559

------------------------------------------------------------------------
[2013-10-16 13:30:37] arjen at react dot com

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 this bug report at https://bugs.php.net/bug.php?id=65915&edit=1


Thread (8 messages)

« previous php.bugs (#182834) next »