ID:               32981
 User updated by:  phpbug at swift-web dot com
 Reported By:      phpbug at swift-web dot com
 Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Gentoo 2.6.11
 PHP Version:      5.0.5-dev
 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------

[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  0x00000000 in ?? ()
#4  0x00000005 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  0x00000103 in ?? ()
#9  0xb7b0ea04 in _emalloc () from /usr/lib/apache2/modules/libphp5.so
#10 0xbffec64c in ?? ()
#11 0xbffec648 in ?? ()
#12 0x00000052 in ?? ()
#13 0xb7a903c0 in zif_vprintf () from
/usr/lib/apache2/modules/libphp5.so
#14 0xbffec644 in ?? ()
#15 0xbffec648 in ?? ()
#16 0xbffec64c in ?? ()
#17 0x00000000 in ?? ()
#18 0x00000000 in ?? ()
#19 0x00000000 in ?? ()
#20 0x00000020 in ?? ()
#21 0x00000001 in ?? ()
#22 0x00000004 in ?? ()
#23 0x00000000 in ?? ()
#24 0x00000000 in ?? ()
#25 0x00000000 in ?? ()
#26 0x00000000 in ?? ()
#27 0x00000000 in ?? ()
#28 0x00000000 in ?? ()
#29 0x00000000 in ?? ()
#30 0x00000000 in ?? ()
#31 0x00000000 in ?? ()
#32 0x20000000 in ?? ()
#33 0x081e9cbc in ?? ()
#34 0x00000000 in ?? ()
#35 0x00000007 in ?? ()
#36 0x00000000 in ?? ()
#37 0x00000000 in ?? ()
#38 0x00000001 in ?? ()
#39 0x00000007 in ?? ()
#40 0x00000000 in ?? ()
#41 0x08220dc4 in ?? ()
#42 0x08220324 in ?? ()
#43 0x0822ed04 in ?? ()
#44 0x00000177 in ?? ()
#45 0x000001e0 in ?? ()
#46 0x00000001 in ?? ()
#47 0x00000000 in ?? ()
(line 47 repeats the same until 450)
#451 0xbffecca8 in ?? ()
#452 0x081f2d64 in ?? ()
#453 0x00000000 in ?? ()
(line 453 repeats the same until 596)
#597 0x73000000 in ?? ()
#598 0xb7d572a0 in ?? () from /lib/libc.so.6
#599 0x00000000 in ?? ()
#600 0x00000000 in ?? ()
#601 0x00000000 in ?? ()
#602 0x00000000 in ?? ()
#603 0x00000000 in ?? ()
#604 0x081ff8cc in ?? ()
#605 0x00000000 in ?? ()
#606 0x00000005 in ?? ()
#607 0x19999999 in ?? ()
#608 0x00000000 in ?? ()
#609 0xb7d6eff4 in ?? () from /lib/libc.so.6
#610 0x081ff8cc in ?? ()
#611 0x00000006 in ?? ()
#612 0xbffecf48 in ?? ()
#613 0xb7c8fefa in __strtol_internal () from /lib/libc.so.6
#614 0x00000004 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 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=32981&edit=1

Reply via email to