Edit report at https://bugs.php.net/bug.php?id=70675&edit=1
ID: 70675
User updated by: maartensc at gmail dot com
Reported by: maartensc at gmail dot com
-Summary: Fatal error: Allowed memory size:zend_execute.c:151
+Summary: method_exists from extended class causes memory
allocation issues
Status: Open
Type: Bug
Package: Class/Object related
Operating System: FreeBSD 10.1-RELEASE
PHP Version: 7.0.0RC4
Block user comment: N
Private report: N
New Comment:
Updated summary to be more accurate.
Previous Comments:
------------------------------------------------------------------------
[2015-10-09 07:56:59] maartensc at gmail dot com
Description:
------------
Good day,
I actually have PHP 7.1.0-dev version compiled from GIT. I used the following to compile:
./configure --enable-fpm --with-pdo-mysql --with-pear --with-openssl --with-curl --with-mcrypt
--with-zlib --enable-zip --with-png-dir --with-jpeg-dir --with-config-file-path=/usr/local/php
--enable-debug --enable-maintainer-zts --enable-cgi --enable-cli
PHP 7.1.0-dev (cli) (built: Oct 8 2015 14:00:51) ( ZTS DEBUG )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
nginx version: nginx/1.8.0
When I run my simplified script below I get the following error.
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted at
/root/php-src/Zend/zend_execute.c:151 (tried to allocate 262176 bytes) in
/usr/local/www/dev/Logs/test.php on line 4
Fatal error: Allowed memory size of 134217728 bytes exhausted at
/root/php-src/Zend/zend_execute.c:151 (tried to allocate 262176 bytes) in
/usr/local/www/dev/Logs/test.php on line 4
The dev machine has 1GB of memory. Memory usage details below.
root@devwebserver:/usr/local/www/dev/Logs # vmstat
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id
0 0 19 1749M 235M 69 0 0 0 80 3 0 0 2 191 88 0 0 100
The above error shows from CLI and when doing request via NGINX -> PHP-FPM.
I have really simplified my script to replicate this issue and as is it might not make too much
sense to use this as is.
Test script:
---------------
<?php
class BaseController{
public function __call(string $Action, array $Data){
if (method_exists($this, $Action . "Action")) {
} elseif (method_exists($this, "DefaultAction") and
$this->DefaultAction($Action, $Data)) {
exit;
}
}
}
class TestPage extends BaseController{
private function DefaultAction(string $Action, array $Data): bool{
return false;
}
}
$testpage = new TestPage();
$testpage->Show();
Expected result:
----------------
Currently the output for this script should be nothing.
Actual result:
--------------
root@webserver:/usr/local/www/dev/Logs # gdb php
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) run /usr/local/www/dev/Logs/test.php
Starting program: /usr/local/bin/php /usr/local/www/dev/Logs/test.php
[New LWP 100084]
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted at
/root/php-src/Zend/zend_execute.c:151 (tried to allocate 262176 bytes) in
/usr/local/www/dev/Logs/test.php on line 4
Fatal error: Allowed memory size of 134217728 bytes exhausted at
/root/php-src/Zend/zend_execute.c:151 (tried to allocate 262176 bytes) in
/usr/local/www/dev/Logs/test.php on line 4
Program exited with code 0377.
(gdb) bt
No stack.
(gdb)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70675&edit=1