Edit report at https://bugs.php.net/bug.php?id=61321&edit=1
ID: 61321 Updated by: larue...@php.net Reported by: lol at nrzw dot net Summary: Crash on __call + __invoke magic -Status: Re-Opened +Status: Closed Type: Bug Package: Reproducible crash Operating System: Linux (CentOS, Deb) PHP Version: 5.3.10 -Assigned To: +Assigned To: laruence Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2012-03-08 13:30:18] larue...@php.net @cataphract it's a knew segfault, that is the call stack exceeded. so I think it's okey to close it. ------------------------------------------------------------------------ [2012-03-08 08:23:38] cataphr...@php.net If it segfaults, there's still a bug. Please don't close it. ------------------------------------------------------------------------ [2012-03-08 02:58:30] lol at nrzw dot net @larue...@php.net I suppose I did =) I don't see how I missed that (I chopped down my code as I am obviously not working with bags). I don't see why this would cause a segfault instead of issuing a failure/warning notice, but that works =) Thank you! ------------------------------------------------------------------------ [2012-03-08 02:53:54] larue...@php.net do you mean like this: <?php class bag { public function e($something) { print_r($something); } public function __invoke($args) { return call_user_func_array(array($this, array_shift($args)), $args); } } class bag_container { public $bagone; public function __construct() { $this->bagone = new bag(); } public function __call($method, array $args = array()) { $this->bagone->__invoke($args); } } $c = new bag_container(); $c->bagone('e', array('wtf')); ------------------------------------------------------------------------ [2012-03-07 22:07:51] lol at nrzw dot net Description: ------------ Using PHP versions 5.3.3 up to 5.3.10: A 'container' has many 'bags', but few methods. Each 'bag' has its own methods that are callable through it's magic __invoke method. No methods collide with the properties of the 'container', so one would expect that: bag_container->bagone('e', array('Some Text')) Would trigger bag_container's __call (since no method 'bagone' exists in 'bag_container'), which would further trigger the __invoke method in class 'bag'. Unfortunately, it just creates a segfault =| I see that there is a related bug (https://bugs.php.net/bug.php?id=53195&edit=2), but since the bug has not been updated and this one produces different behavior (segfault), I felt that I should resubmit. Apologies if that's wrong. Test script: --------------- class bag { public function e($something) { echo $something; } public function __invoke() { return call_user_func_array(array($this, $method), $args); } } class bag_container { public $bagone; public function __construct() { $this->bagone = new bag(); } public function __call($method, array $args = array()) { return call_user_func_array(array($this, $method), $args); } } $c = new bag_container(); $c->bagone('e', array('wtf')); Expected result: ---------------- One would expect 'wtf' to be echo'd. Actual result: -------------- Segmentation fault. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61321&edit=1