Bug #70675 [Opn]: method_exists from extended class causes memory allocation issues

From: Date: Fri, 09 Oct 2015 18:19:47 +0000
Subject: Bug #70675 [Opn]: method_exists from extended class causes memory allocation issues
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196465@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70675&edit=1 ID: 70675 Updated by: marcio@php.net Reported by: maartensc at gmail dot com 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: This doesn't seem to be a bug. Your __call method has infinite recursion. Consider this other example with 'DefaultAction' being defined as 'protected' instead of 'private': https://3v4l.org/l37O8 Previous Comments: ------------------------------------------------------------------------ [2015-10-09 13:30:02] maartensc at gmail dot com Updated summary to be more accurate. ------------------------------------------------------------------------ [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

« previous php.bugs (#196465) next »