|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80532 assigning value to string at high index(1e9) results in out of memory error
Submitted: 2020-12-19 07:50 UTC Modified: 2020-12-20 06:18 UTC
From: Srglmr at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 7.3.25 OS: windows 10 & CentOS 7
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.
Block user comment
Status: Assign to:
Bug Type:
From: Srglmr at gmail dot com
New email:
PHP Version: OS:


 [2020-12-19 07:50 UTC] Srglmr at gmail dot com
$X[1e9]=0; // Allowed memory size of 536870912 bytes exhausted (tried to allocate 1000000032 bytes)

Test script:

Expected result:
i expect an error telling me that i can't assign by index if the variable is string , but instead it shows out of memory error which is very confusing error 

i encountered the error while trying to do something like this $S[Time()]=0;
thinking that $S is an empty array ( $S = [] ) while it was a string $S = "100"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-19 14:18 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-12-19 14:18 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

It is allowed to assign by index if the variable is string[1], and
the behavior is well documented[2].  Of course, you need
sufficient memory (and respective memory_limit) to be able to
create such large strings.

[1] <>
[2] <>
 [2020-12-20 06:18 UTC] Srglmr at gmail dot com
Thanks, it would be much better to have a notice telling me that I assigned a value at an index that is higher than my string length
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Apr 21 21:01:24 2021 UTC