getStaticVariables() causes apache2.0.54 seg fault
| Bug #32981 | ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault | ||||
|---|---|---|---|---|---|
| Submitted: | 2005-05-09 10:15 UTC | Modified: | 2005-08-17 14:26 UTC | ||
| From: | phpbug at swift-web dot com | Assigned: | dmitry (profile) | ||
| Status: | Closed | Package: | Reproducible crash | ||
| PHP Version: | 5.0CVS (2005-05-09) | OS: | Gentoo 2.6.11 | ||
| Private report: | No | CVE-ID: | None | ||
[2005-05-09 10:15 UTC] phpbug at swift-web dot com
Description:
------------
Discovered if I am using ReflectionMethod::getStaticVariables() on a method that has a static variable that is set to boolean true or false then php crashes (Apache 2 exists with following error)
[notice] child pid 28346 exit signal Segmentation fault (11)
I tried with php version 5.0.3 initially but upgraded to 5.0.4 and problem still exists.
Reproduce code:
---------------
class demo_class {
static function myDemo($toggle) {
static $enabled = true;
// do whatever
}
}
$class = new ReflectionClass('demo_class');
foreach ($class->getMethods() as $method) {
$arr_static_vars[] = $method->getStaticVariables();
}
echo "done";
// (normally would output $arr_static_var but just put above
// line for simplicity in this example)
Expected result:
----------------
See a screen with just the word 'done' on it
Actual result:
--------------
Page loading stops immediately (and keeps last page shown displayed. Apache logs show:
[notice] child pid 28346 exit signal Segmentation fault (11)
(pid of course varies)
If I change the third line in my sample code to:
static $enabled = 1;
(or string) the page does not crash and things display properly
I haven't tested this to see if it also crashes showing static variables for the entire class (as opposed to the one in the method) but if they inherit the same code I guess it would also crash but again I haven't confirmed that.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2005-05-10 04:55 UTC] phpbug at swift-web dot com
The script I run that crashes is a class I called ss_debug and it has a dump method that will use the Reflection methods to output into a easy to read table information about a class. I remembered the ss_debug class has methods with static values so I set it to report/parse itself and it ran, but only if I did it at the end of a script that ran normally (If I tried dumping the output at the beginning of a script or just an empty script like entered as an example earlier, it crashed). This confused me why it ran at the end and not at the beginning. I tried adding a new method to this class that simple was: function jason() { static $me = true; } now it crashed all the time (whether I ran it on it's own or after a page that normally worked). Pulled a few hairs out and then it dawned on me to override the default setting in that class before I dumped it and now it works. So what I have narrowed it down to consistently is if I have static variables that are still in their default setting of boolean true or false then it causes a seg fault. If I override the default setting before dumping (running the reflection class/methods) then it works. Did I explain this clear enough?[2005-05-10 14:40 UTC] sniper@php.net
[2005-05-10 17:16 UTC] phpbug at swift-web dot com
[2005-05-11 21:46 UTC] tony2001@php.net
[2005-08-17 14:26 UTC] dmitry@php.net