The longer I work on Greeble, the more PHP bugs I uncover. Here's the latest bug I've found (it's fixed in the latest build of php, but not in the latest release of php, which is what I'm using) (it's Windows only; the identical code runs fine on my Linux box):
PHP Code:
<?php
class A {
static function b($classname) {
//the following two lines run fine:
$x = c();
call_user_func(d, $x);
//as does this line:
d(c());
//this line, however, causes apache to crash. Lovely, eh?
call_user_func(d, c());
}
}
class B extends A{
public static function a() {
parent::b(B);
}
}
function c() {
debug_backtrace();
}
function d($x) {}
B::a(1);
?>
Took me a while to boil it down to its essential components. It requires class inheritance, function overriding, call_user_func, and evaluation of a function in the context of an argument to another function. The crash happens on debug_backtrace().
My suspicion is that there's some sort of infinite loop occuring in debug_backtrace causing a stack overflow.
The bright side is that I can workaround this problem as shown in the two pieces above the disastrous call_user_func, and that the only reason I have a call_user_func in the first place is a workaround for the absence of late static binding in the latest release of php, which won't be necessary much longer.
Bookmarks