|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39132 integer overflow in memory_limit with memory >= 2GB.
Submitted: 2006-10-12 03:17 UTC Modified: 2006-10-20 01:00 UTC
Avg. Score:4.5 ± 0.7
Reproduced:13 of 13 (100.0%)
Same Version:9 (69.2%)
Same OS:8 (61.5%)
From: php at vicaya dot com Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.1.6 OS: Linux 64-bit
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-10-12 03:17 UTC] php at vicaya dot com
Looks like memory_limit is kept using a 32-bit signed integer even with php compiled on 64-bit Linux.

Reproduce code:
set memory_limit to -1 or >= 2048M

<?= count(file("a_big_file")) ?>

Expected result:
number of lines in "a_big_file".

Actual result:
"Integer overflow in memory_limit check detected"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-12 08:05 UTC]
Yes, it's using a size_t which AFAIK is limited to 32bit on most systems.
 [2006-10-12 09:57 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-10-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-01-27 13:55 UTC] vadim at vadiaz dot com
same behavior on 5.2.5
setting memory_limit to 4096M result in almost any script produce following error:

Allowed memory size of 
262144 bytes exhausted

262144 == 0x40000

I put 4000000000 in php.ini and it looks like it work now
so parsing '4096M' does produce memory_limit 4Gb
 [2016-01-25 14:08 UTC] mg at artigo dot pl
Same issue on 5.6.14 64 bit + Apache 64 bit + Windows 64 bit.
Can't set "4096M", getting:
PHP Fatal error:  Allowed memory size of 262144 bytes exhausted
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jan 31 18:03:43 2023 UTC