php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70207 Finally breaks with opcache
Submitted: 2015-08-07 15:55 UTC Modified: 2015-08-09 04:01 UTC
From: james dot h dot cracknell at gmail dot com Assigned: laruence (profile)
Status: Closed Package: opcache
PHP Version: 7.0.0beta3 OS: Windows Server 2008R2
Private report: No CVE-ID: None
 [2015-08-07 15:55 UTC] james dot h dot cracknell at gmail dot com
Description:
------------
I am seeing some very unusual results using opcache with a try block returning the result of a method call with a finally block containing @.

    <?php
    
    function bar() { return 'bar'; }

    function foo() {
      try { return bar(); }
      finally { @fclose(null); }
    }

    var_dump(foo());

opcache, @:
===========
int(22527)

!opcache, @:
============
string(3) "bar"

opcache, !@:
============
Warning: fclose() expects parameter 1 to be resource, null given
bool(false)

!opcache, !@:
=============
Warning: fclose() expects parameter 1 to be resource, null given
string(3) "bar"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-08 02:49 UTC] laruence@php.net
a little more simple reproduce case is :

<?php

function foo() {
    try { return chr(0) . "bar"; }
    finally { @fclose(null); }
}

var_dump(foo());
?>

this is because the new finally's fastcall/fastret layout finish the temp var liveness prematurely... :<
 [2015-08-08 03:41 UTC] laruence@php.net
a simple fix could be : https://gist.github.com/laruence/c18e97cc85f53e0200c0
 [2015-08-09 04:01 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-08-10 13:39 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=18fb424befc5c7e98b91a570752fe6e90a09b330
Log: Fixed bug #70207 (Finally is broken with opcache)
 [2015-08-10 13:39 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2015-08-18 16:24 UTC] ab@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=18fb424befc5c7e98b91a570752fe6e90a09b330
Log: Fixed bug #70207 (Finally is broken with opcache)
 [2016-07-20 11:37 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=18fb424befc5c7e98b91a570752fe6e90a09b330
Log: Fixed bug #70207 (Finally is broken with opcache)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC