php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23395 for loop = infinite loop in RC2
Submitted: 2003-04-28 22:33 UTC Modified: 2003-04-29 10:16 UTC
From: sprice at wisc dot edu Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2RC2 OS: Mac OS X.2.5
Private report: No CVE-ID: None
 [2003-04-28 22:33 UTC] sprice at wisc dot edu
With this loop:
<?php
for( $i = 1; $i <= 10000; $i *= 10 ){
	echo 'foo ';
}
?>

PHP drops into an infinite loop (lots of 'foo' gets 
printed). This problem didn't exist in PHP 4.3.2-RC1.

When changed to "; $i += 10 ){" it works as expected.

When changed to "; $i *= 9 ){" only one 'foo' is 
printed.

When changed to "; $i *= 11 ){" it is infinite.

When changed to "; $i *= 100 ){" only one 'foo' is 
printed.

Weird.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-28 22:35 UTC] sprice at wisc dot edu
I forgot to mention, configure:
./configure --with-apxs
 [2003-04-29 00:30 UTC] sprice at wisc dot edu
BTW:
<?php
$i = 1;
$i *= 10;
echo $i;
?>

yields:
-2123890688
 [2003-04-29 01:23 UTC] derick@php.net
I can not reproduce this at all. 
 [2003-04-29 08:48 UTC] sprice at wisc dot edu
I tried this on another OS X.2.5 Server machine that I 
administer with the same result. Both installations 
were compiled, etc. independently. The first was 10.2.5 
client tho.
 [2003-04-29 09:16 UTC] sprice at wisc dot edu
$i = $i * 10; works just fine. Then when I go back to 
$i *= 10; it breaks again.
 [2003-04-29 09:33 UTC] edink@php.net
I can confirm that:

sapi/cli/php -r '$i=1; $i *= 10; print $i;'

prints

-2123890688

on Mac OS X 10.2.5.

GNU Bison version 1.28
flex version 2.5.4
GCC 3.1 (Apple)

 [2003-04-29 09:49 UTC] edink@php.net
*= operator seems to be broken on windows as well where the example prints 0.

The following commit seems to be the cause.

http://cvs.php.net/diff.php/Zend/zend_operators.c?r1=1.129.2.1&r2=1.129.2.2&ty=u
 [2003-04-29 10:16 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 11:00:02 2026 UTC