|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-22 12:54 UTC] tomas dot matousek at matfyz dot cz
Description:
------------
PHP crashes when an arbitrary function declared in a switch statement is called.
Reproduce code:
---------------
<?
$x = 1;
switch($x)
{
case 1:
function f() { }
break;
}
f();
?>
Expected result:
----------------
no crash
Actual result:
--------------
crash
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 04:00:01 2025 UTC |
The bug exists in the last snapshot php5-200407131230. Tested under FreeBSD 4.9 and Windows XP. (gdb) bt #0 zend_switch_free_handler (execute_data=0xbfbfe314, opline=0x84f8824, op_array=0x8504780) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend_execute.c:65 #1 0x823fbcf in execute (op_array=0x8504780) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend_execute.c:1391 #2 0x825d8c5 in zend_do_fcall_common_helper (execute_data=0xbfbfe404, opline=0x850e368, op_array=0x8505124) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend_execute.c:2728 #3 0x825dd22 in zend_do_fcall_by_name_handler (execute_data=0xbfbfe404, opline=0x850e368, op_array=0x8505124) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend_execute.c:2810 #4 0x823fbcf in execute (op_array=0x8505124) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend_execute.c:1391 #5 0x821e32e in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/ports/lang/php5/work/php-5.0.0RC3/Zend/zend.c:1061 #6 0x81e3ba5 in php_execute_script (primary_file=0xbfbffac0) at /usr/ports/lang/php5/work/php-5.0.0RC3/main/main.c:1627 #7 0x82688ce in main (argc=3, argv=0xbfbffb3c) at /usr/ports/lang/php5/work/php-5.0.0RC3/sapi/cli/php_cli.c:943I have the same problem, example : <? $somecode=1; switch($somecode){ case 1: function test(){ echo "success"; } test(); break; } ?> With php5 final, this code was working with php 4.3.7I experienced this crash on Linux 2.6.3 with PHP 4.3.3 and PHP 5.1.0-dev snapshot 200407271430. Perhaps somebody should set the category to "reproducible crash". This is the PHP 5.1.0-dev backtrace: #0 0x08271843 in zend_switch_free_handler (execute_data=0xbfffd5a0, opline=0x8726fe4, op_array=0x8721970, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/Zend/zend_execute.c:200 200 if (!T(opline->op1.u.var).var.ptr_ptr) { (gdb) bt #0 0x08271843 in zend_switch_free_handler (execute_data=0xbfffd5a0, opline=0x8726fe4, op_array=0x8721970, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/Zend/zend_execute.c:200 #1 0x0826c0b5 in execute (op_array=0x8721970, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/Zend/zend_execute.c:1391 #2 0x0826fe63 in zend_do_fcall_common_helper (execute_data=0xbfffd670, opline=0x8725ecc, op_array=0x8721b94, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/Zend/zend_execute.c:2728 #3 0x0826c0b5 in execute (op_array=0x8721b94, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/Zend/zend_execute.c:1391 #4 0x0824ce31 in zend_execute_scripts (type=8, tsrm_ls=0x8430018, retval=0x0, file_count=3) at /root/php/200407271430/php5-5.0.0/Zend/zend.c:1068 #5 0x08210044 in php_execute_script (primary_file=0xbffffa40, tsrm_ls=0x8430018) at /root/php/200407271430/php5-5.0.0/main/main.c:1631 #6 0x08278bfc in main (argc=2, argv=0xbffffb04) at /root/php/200407271430/php5-5.0.0/sapi/cgi/cgi_main.c:1568I have the similar problem with this. In cli interface everything work right, but the apache web server is segfaults. The code working with php 4.3.8 apache: 2.0.53 php: 5.0.3 The system is Linux/FC3, and FC test /prepre4 :)/ The code: <? $mi=1; switch ($mi) { case 1: function Lufi() { global $cucc; return(666); } break; } echo microtime()."<br>"; echo Lufi(); ?> -- Fonya