php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18927 foreach corrupting array contents
Submitted: 2002-08-15 17:12 UTC Modified: 2002-08-16 10:18 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: mattc at wselectric dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.2.2 OS: Slackware Linux 7.1.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattc at wselectric dot com
New email:
PHP Version: OS:

 

 [2002-08-15 17:12 UTC] mattc at wselectric dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-15 17:15 UTC] mattc at wselectric dot 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-16 10:18 UTC] kalowsky@php.net
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.  
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 08:02:42 2024 UTC