php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Status: Closed Package: Reproducible crash
PHP Version: 5.0CVS (2005-05-09) OS: Gentoo 2.6.11
Private report: No CVE-ID:
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-09 11:36 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Seems to work fine fore me with latest CVS HEAD (5.1-dev) but do try and see if it's fixed in the 5.0 too.

 [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
That backtrace is useless to us. You really didn't configure with --enable-debug. 

Are you using any Zend extensions (any extension loaded with zend_extension in php.ini) ?

 [2005-05-10 17:16 UTC] phpbug at swift-web dot com
I couldn't make sense of the backtrace either.  phpinfo() confirms I have --enable-debug flag set.

I have no Zend extensions loaded.

I don't have apache compiled with --enable-debug.  Is that part of the problem?
 [2005-05-11 21:46 UTC] tony2001@php.net
Nobody is able to reproduce it (me neither), so try to rebuild PHP (grab new snapshot for that) and if you're still able to replicate it, provide more info about your build: configure options, software used etc.
 [2005-08-17 14:26 UTC] dmitry@php.net
Fixed in CVS HEAD (6.0), PHP_5_1 and PHP_5_0.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 03:02:48 2014 UTC