ID:               29735
 User updated by:  sparkeh at btinternet dot com
 Reported By:      sparkeh at btinternet dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Linux 2.6.7-gentoo-r9
 PHP Version:      5.0.1
 New Comment:

There is no loop here. This is segfaulting because the function is
failing to return correctly (stack corruption). Remove the "global"
statement, and add an echo '' outside of the switch() braces to see
normal (expected) program flow.


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

[2004-08-18 17:18:38] sparkeh at btinternet dot com

What loop??

Remove the "global $moo" and the $rar = 0 and it runs as expected:

<?
        switch($t)
        {
                default:
                        function segfault()
                        {
                                echo 'About to segfault : ';
                        }
                        segfault();
        }
        echo 'Or not. Look no loop.';
?>

------------------------------------------------------------------------

[2004-08-18 17:05:03] [EMAIL PROTECTED]

?
You call the function segfault() in a never ending loop.

------------------------------------------------------------------------

[2004-08-18 16:17:19] sparkeh at btinternet dot com

There is no recursion. This is a function being called from within a
switch block. Surely?

------------------------------------------------------------------------

[2004-08-18 15:47:59] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected, PHP does not protect against infinite recursion.

------------------------------------------------------------------------

[2004-08-18 15:24:10] sparkeh at btinternet dot com

Description:
------------
I've tried to get the code to the minimum required to cause a crash.
The combination of the local variable being defined and the global
reference seems to be causing stack corruption (the script never
returns successfully from the function call:

jelly can # php -f crash.php
About to segfault : Segmentation fault
jelly can # php -v
PHP 5.0.1 (cli) (built: Aug 18 2004 12:39:38)

Reproduce code:
---------------
<?
        switch($t)
        {
                default:
                        $rar = 0;
                        function segfault()
                        {
                                global $moo;
                                echo 'About to segfault : ';
                        }
                        segfault();
        }
?>


Expected result:
----------------
About to segfault : 

Actual result:
--------------
About to segfault : Segmentation fault



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29735&edit=1

Reply via email to