Edit report at https://bugs.php.net/bug.php?id=51329&edit=1

 ID:                 51329
 Updated by:         larue...@php.net
 Reported by:        gergely dot fabian at radix-technologies dot com
 Summary:            call_user_func_array() crashes with autoload in
                     recursive calls
-Status:             Not a bug
+Status:             Wont fix
 Type:               Bug
 Package:            Reproducible crash
 Operating System:   Ubuntu
 PHP Version:        5.2.13
 Block user comment: N
 Private report:     N

 New Comment:

Since 5.2 is not supported anymore,  so I only commit the patch here. 
You should always upgrade to a decent version of PHP :)


Previous Comments:
------------------------------------------------------------------------
[2012-04-28 07:25:15] larue...@php.net

The following patch has been added/updated:

Patch Name: bug51329.patch
Revision:   1335597915
URL:        
https://bugs.php.net/patch-display.php?bug=51329&patch=bug51329.patch&revision=1335597915

------------------------------------------------------------------------
[2010-07-09 09:48:01] ivo at danihelka dot net

I simplified the test case.
It is not needed to create the classes on disk.

Test script:
------------
$limit = 50;

function __autoload($class_name) {
    eval("
echo \"$class_name loaded\\n\";
class $class_name {
  public static function execute_me(){
    return \"$class_name executed\\n\";
  }
}");
}

function go_deeper($limit, $i = 1){
  echo call_user_func_array(array("P$i", 'execute_me'), array());
  if($i < $limit) go_deeper($limit, $i+1);
}

go_deeper($limit);
echo "Success\n";

------------------------------------------------------------------------
[2010-07-09 08:34:12] denis at bitrix dot ru

I have the same problem. Why is it bogus? There is no unlimit recursion!
The only workaround I found is not to use autoload.

------------------------------------------------------------------------
[2010-03-22 07:40:00] gergely dot fabian at radix-technologies dot com

I have to emphasize that the use case where this bug came out was not infinite 
recursion. 
It is in an MVC web application framework (symfony) that a given amount of 
filters (let's say 15) are one-by-one called by the filterChain's execute() 
method, and then call back to filterChain->execute() (thus making a sort of 
indirect recursion).
In our case if we have certain conditions true and have a 7th filter, then a 
later call_user_func_array call will cause a segfault. Having less number of 
filters (disabling any of them) "fixes" the bug (not reaching that amount of 
recursion), as also having one more filter (making an additional recursion 
step).
The second testcase reproduces this with plain PHP code.

------------------------------------------------------------------------
[2010-03-22 07:24:26] gergely dot fabian at radix-technologies dot com

The infinite recursion that you mentioned also causes segfault, but it's 
another case. If I remove the call_user_func_array call, and the limit of 50, 
then it will segfault after around 14860 recursive calls (on my machine).
My original code (and the second version I posted) segfaults at 25/31st 
recursion. That's a different amount I'd say.
If I change the second version of my testcase to jump call_user_func_array call 
at 25th recursion, then it runs until 208th recursion and dies again on 
call_user_func_array.
If enable though class_exists() before call_user_func_array(), then recursion 
is successful for both 25th and 208th.

------------------------------------------------------------------------


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=51329


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=51329&edit=1

Reply via email to