[PHP-DEV] Bug #11218 Updated: isset() inside for() loops can crash
ID: 11218 User Update by: [EMAIL PROTECTED] Old-Status: Feedback Status: Open Bug Type: Scripting Engine problem Operating system: NT 4.0 SP6a PHP Version: 4.0.5 Description: isset() inside for() loops can crash Tested latest snapshot, http://www.zend.com/snapshots/get_latest.php, as of 17:00 -400. The problem with isset() inside for loops is fixed. BUT, there is still a problem. Testing a multidimensional array when only one dimension of the array is set causes the test to come out true even when it is not. See example: http://bugs.php.net/?id=11218 # # This "if isset()" test comes out as true # even though it's actually false. echo 'Should not see anything else after this...'; $Var['SC'] = 'y'; if ( isset($Var['SC']['hide']) ) { echo "isset() says \$Var['SC']['hide'] is set."; } ?> PS: I'm saddened to hear new versions of PHP are going out with unresolved bugs in functions as basic and essential as isset(). Previous Comments: --- [2001-06-21 12:14:07] [EMAIL PROTECTED] I was unable to reproduce that problem, however, I did fix bug #10911 which appears to be based on the same issue. Can you please test the latest CVS and see whether it solves your problem (note, this fix may not be a part of 4.0.6, since 4.0.6 has already been packaged; It'll definitely be in 4.0.7) --- [2001-06-05 17:20:08] [EMAIL PROTECTED] Bug 10911, http://www.php.net/bugs.php?id=10911, was brought to my attention. Both my report above and this other one may be based on the same bug. --- [2001-05-31 12:33:40] [EMAIL PROTECTED] in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__); # NOW, funny things happen if I change the number of times # the for loop runs... # $Counter < 1... # Everything is fine. # $Counter < 2... # Dr Watson notifys of PHP crash, hit OK # (SeeDr Watson report at end of this posting.) # Text is displayed in browser. # PHP no longer running. # $Counter < 3... # Nothing returned to browser. # No Dr Watson reports. # PHP won't stop executing, takes up 99% of processor time. # Can't "End Process" in Task Manger. # Doesn't stop after max execution time. # Need to reboot to kill PHP process. # # Though, if I execute from command line... # winds up in same infinite loop, but I can # kill the PHP process from the task manager. # So, if that's not strange enough, altering the # test code in small ways eliminates the problem... # remove if / isset segment... # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; } } Test(__FILE__,__LINE__); */ # put the if / isset segment back # BUT remove the for loop # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } Test(__FILE__,__LINE__); */ # put the for loop back # BUT do isset on a single dimensional array... # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__); */ # perform tasks outside a function. # okay /* for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } */ # set the array before running function # okay /* $Var['SC']['hide'] = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__,'',$Var); */ # Set a single dimensional array, # though continue to perform isset on a two dimensional # Doesn't crash # --> _BUT_ the "if isset()" test comes out as TRUE # --> even when it's actually FALSE! /* unset($Var); $Var['SC'] = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__,'',$Var); */ # Set variable to a string... # okay /* $Var = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++
[PHP-DEV] Bug #11218 Updated: isset() inside for() loops can crash
ID: 11218 Updated by: zeev Reported By: [EMAIL PROTECTED] Old-Status: Open Status: Feedback Bug Type: Scripting Engine problem Operating system: PHP Version: 4.0.5 Assigned To: Comments: I was unable to reproduce that problem, however, I did fix bug #10911 which appears to be based on the same issue. Can you please test the latest CVS and see whether it solves your problem (note, this fix may not be a part of 4.0.6, since 4.0.6 has already been packaged; It'll definitely be in 4.0.7) Previous Comments: --- [2001-06-05 17:20:08] [EMAIL PROTECTED] Bug 10911, http://www.php.net/bugs.php?id=10911, was brought to my attention. Both my report above and this other one may be based on the same bug. --- [2001-05-31 12:33:40] [EMAIL PROTECTED] in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__); # NOW, funny things happen if I change the number of times # the for loop runs... # $Counter < 1... # Everything is fine. # $Counter < 2... # Dr Watson notifys of PHP crash, hit OK # (SeeDr Watson report at end of this posting.) # Text is displayed in browser. # PHP no longer running. # $Counter < 3... # Nothing returned to browser. # No Dr Watson reports. # PHP won't stop executing, takes up 99% of processor time. # Can't "End Process" in Task Manger. # Doesn't stop after max execution time. # Need to reboot to kill PHP process. # # Though, if I execute from command line... # winds up in same infinite loop, but I can # kill the PHP process from the task manager. # So, if that's not strange enough, altering the # test code in small ways eliminates the problem... # remove if / isset segment... # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; } } Test(__FILE__,__LINE__); */ # put the if / isset segment back # BUT remove the for loop # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } Test(__FILE__,__LINE__); */ # put the for loop back # BUT do isset on a single dimensional array... # okay /* function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__); */ # perform tasks outside a function. # okay /* for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } */ # set the array before running function # okay /* $Var['SC']['hide'] = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__,'',$Var); */ # Set a single dimensional array, # though continue to perform isset on a two dimensional # Doesn't crash # --> _BUT_ the "if isset()" test comes out as TRUE # --> even when it's actually FALSE! /* unset($Var); $Var['SC'] = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__,'',$Var); */ # Set variable to a string... # okay /* $Var = 'y'; function Test($FileName, $FileLine, $Opt='', $Col='') { for ($Counter = 0; $Counter < 3; $Counter++) { echo 'in for '; if ( isset($Col['SC']['hide']) ) { echo 'in if'; } } } Test(__FILE__,__LINE__,'',$Var); */ /* Application exception occurred: App: (pid=212) When: 5/31/2001 @ 11:59:23.314 Exception number: c005 (access violation) *> System Information <* Computer Name: BASE User Name: SYSTEM Number of Processors: 1 Processor Type: x86 Family 6 Model 3 Stepping 4 Windows Version: 4.0 Current Build: 1381 Service Pack: 6 Current Type: Uniprocessor Free Registered Organization: Analysis and Solutions Company Registered Owner: Daniel Convissor *> Task List <* 0 Idle.exe 2 System.exe 20 SMSS.exe 24 CSRSS.exe 34 winlogon.exe 40 SERVICES.exe 43 LSASS.exe 66 SPOOLSS.exe