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

 ID:               51329
 Comment by:       ivo at danihelka dot net
 Reported by:      gergely dot fabian at radix-technologies dot com
 Summary:          call_user_func_array() crashes with autoload in
                   recursive calls
 Status:           Bogus
 Type:             Bug
 Package:          Reproducible crash
 Operating System: Ubuntu
 PHP Version:      5.2.13

 New Comment:

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";


Previous Comments:
------------------------------------------------------------------------
[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.

------------------------------------------------------------------------
[2010-03-21 21:59:57] gergely dot fabian at radix-technologies dot com

This is not infinite recursion (is 31/25 recursion too deep?).

See my comment with putting one element to call stack "fixing" later
autoloading (2010-03-19 09:38 UTC).

This is an autoloading/call_user_func_array bug imho. Otherwise if it
would be normal for this to happen, why does class_exists() call right
before the segfaulting place fix it?

------------------------------------------------------------------------
[2010-03-21 19:24:32] johan...@php.net

Infinite recursion is known to segfault and expected behavior. See other
reports about it.

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


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

    http://bugs.php.net/bug.php?id=51329


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

Reply via email to