php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69549 Memory leak with opcache.optimization_level=0xFFFFFFFF
Submitted: 2015-04-30 02:05 UTC Modified: 2015-04-30 17:06 UTC
From: naoki-kawamukai at cybozu dot co dot jp Assigned: dmitry (profile)
Status: Closed Package: opcache
PHP Version: 5.5Git-2015-04-30 (Git) OS: Debian 7.8
Private report: No CVE-ID: None
 [2015-04-30 02:05 UTC] naoki-kawamukai at cybozu dot co dot jp
Description:
------------
This leaks occurs on PHP 5.5(Git-2015-04-30), PHP 5.6(Git-2015-04-30).
But it does not occur on PHP 7.0(Git-2015-04-30)

My opcache configuration:
vagrant@php7dev:~$ php -i | grep opcache
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 256 => 256
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On


Test script:
---------------
<?php
$a = array(true);
if($a[0] && false) {
  echo 'test';
}
?>

Expected result:
----------------
Nothing happen.

Actual result:
--------------
Memory leaks.

vagrant@php7dev:~$ php -d opcache.enable_cli=1 -d opcache.optimization_level=0xFFFFFFFF leak.php
[Thu Apr 30 01:42:30 2015]  Script:  '/home/vagrant/leak.php'
/home/vagrant/php-src/Zend/zend_vm_execute.h(6257) :  Freeing 0x7F6A57B167E0 (32 bytes), script=/home/vagrant/leak.php
=== Total 1 memory leaks detected ===


When disabling opcache optimization, memory does not leak.

vagrant@php7dev:~$ php -d opcache.enable_cli=1 -d opcache.optimization_level=0 leak.php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-30 03:01 UTC] laruence@php.net
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: dmitry
 [2015-04-30 03:01 UTC] laruence@php.net
side affects by block pass optimization..
 [2015-04-30 12:08 UTC] laruence@php.net
instead of fix optimization in cfg ..

maybe we should insert some ZEND_FREE, considering following test script, the FETCH_OBJ_R should not be optimized away:

<?php
class A {
	public function __get($name) {
		echo "__get: $name";
		return "$name";
	}
}

$a = new A;

if ($a->true && false) {
	echo "bad";
}

thanks
 [2015-04-30 17:06 UTC] laruence@php.net
A quick fix is attached(which could show where the problem is): https://gist.github.com/laruence/153a3ad7ea739507c025
 [2015-05-07 09:18 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8026001943109dea3f908b8dd0720a0de9781af6
Log: Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF)
 [2015-05-07 09:18 UTC] dmitry@php.net
-Status: Analyzed +Status: Closed
 [2015-05-07 09:19 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8026001943109dea3f908b8dd0720a0de9781af6
Log: Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC