#18927 [Opn->]: foreach corrupting array contents

From: Date: Fri, 16 Aug 2002 14:18:43 +0000
Subject: #18927 [Opn->]: foreach corrupting array contents
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-17017@lists.php.net to get a copy of this message
ID: 18927 Updated by: kalowsky@php.net Reported By: mattc@wselectric.com -Status: Open +Status: Won't fix Bug Type: Scripting Engine problem Operating System: Slackware Linux 7.1.0 PHP Version: 4.2.2 New Comment: It's not really a problem, or a bug. You've hit the maximum value of a short int, which is how the Zend engine marks references. The ZendEngine2 fixes, this but I'm doubtful you'll see this fixed in the current ZE1. Previous Comments: ------------------------------------------------------------------------ [2002-08-15 17:15:12] mattc@wselectric.com I originally experienced this problem on version 4.1.2 (same configure options), before upgrading -- only to find the problem still existed. ------------------------------------------------------------------------ [2002-08-15 17:12:50] mattc@wselectric.com Running my sample script with the loop set up to 65534 times will run without corrupting the array $a. If you run it as 65535 times or more, the array is corrupted, and the value of $b becomes an array, which then causes the following warnings to be generated: PHP Warning: Illegal offset type in /home/web/dev/docs/lookup/bug.php on line 9 Obviously the foreach and array assignments should not be corrupting the contents of array $a. Sample script: <script language="php"> $a = array(1); foreach($a as $b) { for($c = 0; $c < 65535; $c++) { $d = 1; $e[$d][] = array($b, $c); $f[$b][$c][] = $d; } } </script> done Configure command: ./configure \ --with-mysql=/usr/local/mysql \ --with-apxs=/usr/local/apache/bin/apxs \ --enable-ftp \ --enable-track-vars \ --enable-versioning \ --with-zlib ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18927&edit=1

« previous php.bugs (#17017) next »