Bug #68648 [Com]: call_user_func inside __callStatic cause segmentation fault

From: Date: Wed, 14 Jan 2015 07:34:00 +0000
Subject: Bug #68648 [Com]: call_user_func inside __callStatic cause segmentation fault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189947@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68648&edit=1 ID: 68648 Comment by: valentiny510 at gmail dot com Reported by: valentiny510 at gmail dot com Summary: call_user_func inside __callStatic cause segmentation fault Status: Not a bug Type: Bug Package: Reproducible crash Operating System: Windows 8 x64 PHP Version: 5.6.4 Block user comment: N Private report: N New Comment: Nikic, I did not called __callStatic( ) method... PHP internally did it Like Claudiu said, 'is_callable' should only determine if the method IS CALLABLE and not actually CALL him self over and over Is like asking yourself in front of a mirror.. "I'm a man ?, I'm a man ?, I'm a man ?" Dude, once you have determined you are a man, just stop... Requinix, 'PHP crashing randomly is a bug'... What can I say... read http://en.wikipedia.org/wiki/Software_bug and seriously.. consider medicine as alternative Previous Comments: ------------------------------------------------------------------------ [2015-01-07 20:27:07] requinix@php.net > Why you cant do something similar to this ? It's quite possible that I want the current function to call itself. Rare, I'll admit, but as a developer I wouldn't want PHP to prevent me from doing that. More likely is that function A calls function B which calls A. Or maybe there's a third function C. Maybe it looks infinitely recursive but there's a condition that will eventually stop it (as happens with typical recursion). It's just not possible for PHP to accurately judge that it should stop executing. On a related note, the xdebug extension can impose a limit on the call stack with its xdebug.max_nesting_level setting. Default of 100. > If an internal function can break the server you just call this "Not a bug" ? PHP crashing randomly is a bug. The developer inadvertently telling PHP to do something bad and thus causing it to crash *might* not be a bug. In this case it wasn't because PHP dutifully carried out the instructions it was given, which happened simply because the submitter didn't know that is_callable() will accommodate for __callStatic (and __call) as opposed to merely checking that a method exists like, well, method_exists(). ------------------------------------------------------------------------ [2015-01-07 17:03:40] nikic@php.net is_callable() does what you says. It does not cause infinite recursion. You are causing infinite recursion, by recursively calling the __callStatic() method. ------------------------------------------------------------------------ [2015-01-07 16:48:26] claudiu at paun dot com BTW, You said the problem is 'is_callable', so in my opinion 'is_callable' should only determine if the method IS CALLABLE and not actually CALL the method and avoiding this way the "infinite recursion"... ------------------------------------------------------------------------ [2015-01-07 16:36:53] claudiu at paun dot com Well done requinix, well done, you just solved all the problems by using the button "Not a bug" and washed your hands. If an internal function can break the server you just call this "Not a bug" ? Dude, seriously, why dont you studied medicine ? ------------------------------------------------------------------------ [2014-12-25 05:32:49] valentiny510 at gmail dot com Ok, my bad using is_callable, but even so, the method should have a limit for the recursion or try to detect if the tested callable method is the same method from where was called and this way avoit the problem, in my opinion is still a bug but for is_callable. Why you cant do something similar to this ? function is_callable($method) { if ($method == __FUNCTION__) return; break; whatever... # Do the loop here... } the thing is, php should never have the ability to break other things like in this case the apache, run in some sandbox style, test the code in the background and then push into some opcache Cheers ! ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=68648 -- Edit this bug report at https://bugs.php.net/bug.php?id=68648&edit=1

« previous php.bugs (#189947) next »