php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69423 Crashing on recursive magic method calling
Submitted: 2015-04-10 22:22 UTC Modified: 2015-04-11 00:42 UTC
From: contact at geolim4 dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.6.7 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: contact at geolim4 dot com
New email:
PHP Version: OS:

 

 [2015-04-10 22:22 UTC] contact at geolim4 dot com
Description:
------------
When you call a method through callStatic() and pass the method name to call_user_func_array(), php is crashing expectedly. It look stupid, but php shouldn't return a fatal error in that case instead of crashing?

Apache error log:
____________________
[Sat Apr 11 00:08:19 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28762) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:08:19 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28761) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:08:43 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28765) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:08:43 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28764) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:08:48 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28767) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:08:48 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28766) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:10:51 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28884) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:10:51 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28802) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:13:02 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28912) exit(communication error), get unexpected signal 11
[Sat Apr 11 00:13:02 2015] [error] mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter_web5(28911) exit(communication error), get unexpected signal 11


Test script:
---------------
http://pastebin.com/5p4cWHp3

Expected result:
----------------
A fatal error

Actual result:
--------------
A fcgi process crash.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-10 23:29 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-04-10 23:29 UTC] requinix@php.net
public static function __callStatic($name, array $arguments)
{
    return call_user_func_array( [__CLASS__, $name], $arguments );
}

Infinite recursion. Typically one of two things will happen:
1. There's enough code executing during the recursion that you hit PHP's configured memory limit, which is a fatal error.
2. Stack overflow, which the system responds to by segfaulting the process, and that's not under PHP's control. This is what's happening to you.

If you're concerned about infinite recursion during development, install Xdebug and configure the max_nesting_level setting.
http://xdebug.org/docs/basic#max_nesting_level

Regarding that code, it is only good for attempting to call a private/protected static member from outside the allowed scope; public static methods never need to be wrapped by __callStatic().
Since it will also be called for any non-existent method you should always validate $name.
 [2015-04-11 00:42 UTC] contact at geolim4 dot com
Ok, i just thought it had to be flag as a fatal error, but if it's a stack overflow like your said then it's totally understandable.
Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 07:02:12 2024 UTC