From:
Operating system: Linux (CentOS, Deb)
PHP version: 5.3.10
Package: Reproducible crash
Bug Type: Bug
Bug description:Crash on __call + __invoke magic
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 bug report at https://bugs.php.net/bug.php?id=61321&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61321&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61321&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61321&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61321&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61321&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61321&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61321&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61321&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61321&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61321&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61321&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61321&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61321&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61321&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61321&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61321&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61321&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61321&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61321&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61321&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61321&r=mysqlcfg