#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 PHP Version: 5.0CVS (2005-05-09) New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. Previous Comments: [2005-07-12 19:07:14] phpbug at swift-web dot com Sorry for the long delay in getting back to this. Tried using just a plain php install as suggested (./configure --enable-debug --with-apxs2=/usr/sbin/apxs2) and I was still getting the seg fault error consistently on two different test boxes. I tried looking at my code again and came up with an idea. if a class has the static variables defined within the class but outside the methods eg: class test { private static $test = true; public function test_method() { // do whatever and access the // static property as: self::$test } } then no seg faults occur when I dump this classes details with my dump class which uses ReflectionMethod::getStaticVariables(). If however the above class is done this way instead (with the static value only used in the method not in entire class): class test { public function test_method() { static $test = true; // do whatever and access the // static property just as $test } } Then using my debug dump class to display information about the class causes a seg fault. I haven't given you my debug/dump class, maybe this is what you need to reproduce the seg fault crash. I'll include the class below. To use the dump class I simply call it statically debug::dump($new = new test(),'test class',true,true); *(replace test() with the name of the class you want information about obviously but my test about used the name test) here is the class // start of php code class debug{ /** * dump out variables to easy to read html tables * variable can be array, string, boolean, object or hash mixture * * @param mix $data variable to be dumped * str $labeloptional top label for table * boo $show_docs true = show documentation for an object item *false (default) = do not show docs for an object item * boo $public_only true (default) = when displaying objects only * show public items *false = show everything about the object * * returns html output */ final public static function dump($data,$label='',$show_docs=false,$public_only=true) { // make sure public_only show_docs is just true or false $public_only = ($public_only != false) ? true : false; $show_docs = ($show_docs != false) ? true : false; // setup styles for html output $style['key'] = 'font-family: sans-serif; text-align: right; font-size: 12px; font-weight: bold; background-color: #000; color: #f0f0f0;'; $style['value'] = 'font-family: sans-serif; font-size: 11px; color: #009; background-color: #eee'; // monospace $style['type'] = 'font-family: sans-serif; text-align: center; font-size: 12px; background-color: #9cc; color: #600;';//#F6F6F6 $output = 'table border=2 bordercolor=#80 cellpadding=0 cellspacing=0trtd style=font-family: sans-serif; font-size: 14px; background-color: #80; color: white;'.($label != '' ? $label : 'variable dump - no variable name passed').'/td/trtrtd style=font-family: sans-serif; text-align: center; font-size: 12px; background-color: #9cc; color: #600;'.gettype($data).'/td/trtrtd'; return($output.ss_debug::dump_html_table($data,$style,$show_docs,$public_only).'/td/tr/tablebr /'); } /** * used privately by dump method */ final private static function dump_html_table($data,$style,$show_docs,$public_only) { if (!is_array($data)) { if ($data === NULL) {
#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 PHP Version: 5.0CVS (2005-05-09) New Comment: Try it with plain ./configure --enable-debug --with-apxs2=/usr/sbin/apxs2 Previous Comments: [2005-05-12 18:08:13] phpbug at swift-web dot com Tried today's CVS snapshot and it still gives a seg fault error. I think I discovered problem with the debugging. I just noticed when I compile with --enable-debug I get warning messages in error_log saying that my modules were not compiled with the debug flag set and they must be. I tried with --disable-debug so I didn't get those warnings and apache starts cleanly (no warning messages). Still get seg fault error. I'll compile the 13 extension modules I need to set the debug flag on for again as well (opensll, mhash, zlib, gettext, tidy, exif, fam, ncurses, mbstring, mcrypt, sysvmsg, sysvsem, sysvshm). I won't have time to do this for a few days though. I configured php with: --prefix=/usr --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-t1lib=/usr --with-ttf=/usr --enable-gd-jis-conf --enable-gd-native-ttf --with-png-dir=/usr --with-tiff-dir=/usr --without-xpm-dir --with-gd --with-mysql --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-mm --without-msession --enable-sqlite-utf8 --with-apxs2=/usr/sbin/apxs2 --with-config-file-path=/etc/php/apache2-php5 --without-pear --disable-bcmath --without-bz2 --disable-calendar --without-cpdflib --disable-ctype --without-curl --without-curlwrappers --disable-dbase --disable-dio --enable-exif=shared --with-fam=shared --without-fbsql --without-fdftk --disable-filepro --disable-ftp --with-gettext=shared --without-gmp --without-hwapi --without-iconv --without-informix --without-ingres --without-interbase --without-kerberos --enable-mbstring=shared --with-mcrypt=shared --without-mcve --disable-memory-limit --with-mhash=shared --without-mime-magic --without-ming --without-mnogosearch --without-msql --without-mssql --with-ncurses=shared --without-oci8 --without-oracle --with-openssl=shared --with-openssl-dir=/usr --without-ovrimos --disable-pcntl --without-pfpro --without-pgsql --disable-posix --without-pspell --without-recode --disable-simplexml --enable-shmop --without-snmp --disable-soap --disable-sockets --without-sybase --without-sybase-ct --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared --with-tidy=shared --disable-tokenizer --disable-wddx --without-xsl --without-xmlrpc --disable-yp --with-zlib=shared --disable-debug --disable-dba --with-readline --without-libedit I have apache-2.0.54-r3 compiled with mpm-prefork and ssl flags set. Here is a complete cut 'n paste of the script I run to display class information along with comments on how I can make it work (*note you'll also see a comment out where isDestructor() always returns true as well) ---start of code--- ?php // test for php Reflection bug (default static property value crash) ?html head titleTest for php Reflection bug/title /head body centerh1Test for php Reflection bug/h1/center hr ?php // phpinfo(); exit; /* * works when I call the below method (that overrides default static property) * but when commented out page exits immediately */ // debug::jason(); echo debug::dump(new debug(),'debug()',0,true); // When I either comment out (or activate) line debug::jason();, // I change the text below to give a quick visual confirmation that // page is not actually fully running when I reload the page echo 'done'; echo '/body/html'; // classes defined below class debug { final public static function jason($jason = true) { static $mark = false; if ($jason !== false) { $mark = $jason; } else { return($mark); } } final public static function dump($data,$label='',$public_only=true,$show_docs=false) { // make sure public_only show_docs is just true or false $public_only = ($public_only != false) ? true : false; $show_docs = ($show_docs != false) ? true : false; // setup styles for html output $style['key'] = 'font-family: sans-serif; text-align: right; font-size: 12px; font-weight: bold; background-color: #000; color: #f0f0f0;'; $style['value'] =
#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 PHP Version: 5.0CVS (2005-05-09) New Comment: 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. Previous Comments: [2005-05-10 17:16:44] 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-10 14:40:14] [EMAIL PROTECTED] 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 04:55:33] 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 04:01:09] phpbug at swift-web dot com Couldn't get a core file (even though compiled with --enable-debug) so I ran httpd -X under gdb cut 'n paste bt results here: #0 0xb7cca595 in memcpy () from /lib/libc.so.6 #1 0xb7a90f71 in zif_vprintf () from /usr/lib/apache2/modules/libphp5.so #2 0x0822ee7b in ?? () #3 0x in ?? () #4 0x0005 in ?? () #5 0xb7b2411e in zend_make_printable_zval () from /usr/lib/apache2/modules/libphp5.so #6 0xbffed060 in ?? () #7 0xb7b99b20 in php_tiff_bytes_per_format () from /usr/lib/apache2/modules/libphp5.so #8 0x0103 in ?? () #9 0xb7b0ea04 in _emalloc () from /usr/lib/apache2/modules/libphp5.so #10 0xbffec64c in ?? () #11 0xbffec648 in ?? () #12 0x0052 in ?? () #13 0xb7a903c0 in zif_vprintf () from /usr/lib/apache2/modules/libphp5.so #14 0xbffec644 in ?? () #15 0xbffec648 in ?? () #16 0xbffec64c in ?? () #17 0x in ?? () #18 0x in ?? () #19 0x in ?? () #20 0x0020 in ?? () #21 0x0001 in ?? () #22 0x0004 in ?? () #23 0x in ?? () #24 0x in ?? () #25 0x in ?? () #26 0x in ?? () #27 0x in ?? () #28 0x in ?? () #29 0x in ?? () #30 0x in ?? () #31 0x in ?? () #32 0x2000 in ?? () #33 0x081e9cbc in ?? () #34 0x in ?? () #35 0x0007 in ?? () #36 0x in ?? () #37 0x in ?? () #38 0x0001 in ?? () #39 0x0007 in ?? () #40 0x in ?? () #41 0x08220dc4 in ?? () #42 0x08220324 in ?? () #43 0x0822ed04 in ?? () #44 0x0177 in ?? () #45 0x01e0 in ?? () #46 0x0001 in ?? () #47 0x in ?? () (line 47 repeats the same until 450) #451 0xbffecca8 in ?? () #452 0x081f2d64 in ?? () #453 0x in ?? () (line 453 repeats the same until 596) #597 0x7300 in ?? () #598 0xb7d572a0 in ?? () from /lib/libc.so.6 #599 0x in ?? () #600 0x in ?? () #601 0x in ?? () #602 0x in ?? () #603 0x in ?? () #604 0x081ff8cc in ?? () #605 0x in ?? () #606 0x0005 in ?? () #607 0x1999 in ?? () #608 0x in ?? () #609 0xb7d6eff4 in ?? () from /lib/libc.so.6 #610 0x081ff8cc in ?? () #611 0x0006 in ?? () #612 0xbffecf48 in ?? () #613 0xb7c8fefa in __strtol_internal () from /lib/libc.so.6 #614 0x0004 in ?? () [2005-05-10 00:52:01] [EMAIL PROTECTED] Thank you for this bug
#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 -PHP Version: 5.0.5-dev +PHP Version: 5.0CVS (2005-05-09) New Comment: 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) ? Previous Comments: [2005-05-10 04:55:33] 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 04:01:09] phpbug at swift-web dot com Couldn't get a core file (even though compiled with --enable-debug) so I ran httpd -X under gdb cut 'n paste bt results here: #0 0xb7cca595 in memcpy () from /lib/libc.so.6 #1 0xb7a90f71 in zif_vprintf () from /usr/lib/apache2/modules/libphp5.so #2 0x0822ee7b in ?? () #3 0x in ?? () #4 0x0005 in ?? () #5 0xb7b2411e in zend_make_printable_zval () from /usr/lib/apache2/modules/libphp5.so #6 0xbffed060 in ?? () #7 0xb7b99b20 in php_tiff_bytes_per_format () from /usr/lib/apache2/modules/libphp5.so #8 0x0103 in ?? () #9 0xb7b0ea04 in _emalloc () from /usr/lib/apache2/modules/libphp5.so #10 0xbffec64c in ?? () #11 0xbffec648 in ?? () #12 0x0052 in ?? () #13 0xb7a903c0 in zif_vprintf () from /usr/lib/apache2/modules/libphp5.so #14 0xbffec644 in ?? () #15 0xbffec648 in ?? () #16 0xbffec64c in ?? () #17 0x in ?? () #18 0x in ?? () #19 0x in ?? () #20 0x0020 in ?? () #21 0x0001 in ?? () #22 0x0004 in ?? () #23 0x in ?? () #24 0x in ?? () #25 0x in ?? () #26 0x in ?? () #27 0x in ?? () #28 0x in ?? () #29 0x in ?? () #30 0x in ?? () #31 0x in ?? () #32 0x2000 in ?? () #33 0x081e9cbc in ?? () #34 0x in ?? () #35 0x0007 in ?? () #36 0x in ?? () #37 0x in ?? () #38 0x0001 in ?? () #39 0x0007 in ?? () #40 0x in ?? () #41 0x08220dc4 in ?? () #42 0x08220324 in ?? () #43 0x0822ed04 in ?? () #44 0x0177 in ?? () #45 0x01e0 in ?? () #46 0x0001 in ?? () #47 0x in ?? () (line 47 repeats the same until 450) #451 0xbffecca8 in ?? () #452 0x081f2d64 in ?? () #453 0x in ?? () (line 453 repeats the same until 596) #597 0x7300 in ?? () #598 0xb7d572a0 in ?? () from /lib/libc.so.6 #599 0x in ?? () #600 0x in ?? () #601 0x in ?? () #602 0x in ?? () #603 0x in ?? () #604 0x081ff8cc in ?? () #605 0x in ?? () #606 0x0005 in ?? () #607 0x1999 in ?? () #608 0x in ?? () #609 0xb7d6eff4 in ?? () from /lib/libc.so.6 #610 0x081ff8cc in ?? () #611 0x0006 in ?? () #612 0xbffecf48 in ?? () #613 0xb7c8fefa in __strtol_internal () from /lib/libc.so.6 #614 0x0004 in ?? () [2005-05-10 00:52:01] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php Once you have generated a backtrace, please submit it to this bug report and change the status back to Open. Thank you for helping us make PHP better. I can't reproduce it - neither with 5_0-dev nor 5.1-dev [2005-05-09 22:19:07] phpbug at swift-web dot com Tried with the latest stable 5.0 (from the link you sent) and the page still crashes with seg fault
#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 PHP Version: 5.0.4 New Comment: 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. Previous Comments: [2005-05-09 10:15:43] 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. -- Edit this bug report at http://bugs.php.net/?id=32981edit=1
#32981 [Opn-Fbk]: ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault
ID: 32981 Updated by: [EMAIL PROTECTED] Reported By: phpbug at swift-web dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Gentoo 2.6.11 PHP Version: 5.0.5-dev New Comment: Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php Once you have generated a backtrace, please submit it to this bug report and change the status back to Open. Thank you for helping us make PHP better. I can't reproduce it - neither with 5_0-dev nor 5.1-dev Previous Comments: [2005-05-09 22:19:07] phpbug at swift-web dot com Tried with the latest stable 5.0 (from the link you sent) and the page still crashes with seg fault error. The version reported in phpinfo is 5.0.5-dev from that install. [2005-05-09 11:36:40] [EMAIL PROTECTED] 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-09 10:15:43] 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. -- Edit this bug report at http://bugs.php.net/?id=32981edit=1