Bug #81070 [NEW]: Regression in 7.4.6 when yielding an array based generator
From: pvandommelen at gmail dot com
Operating system:
PHP version: 7.3.28
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Regression in 7.4.6 when yielding an array based generator
Description:
------------
When more memory is allocated, the currently allocated memory is
compared to the limit. There is currently an integer underflow problem
when the limit is lower than the currently allocated memory. This can
occur when the memory limit is changed dynamically through
set_ini("memory_limit", ..).
This was introduced in 7.2.23 and also exists in 7.3.10 and all versions
of 7.4 and 8.0.
https://github.com/php/php-src/commit/16d35eb643bf974554e5264021ee10fc969e2053
The code sample illustrates the problem. Allocation after the memory
limit is reduced should throw an error.
The old behaviour can probably be reintroduced by also verifying that
the memory limit is higher than the currently allocated memory.
Test script:
---------------
https://3v4l.org/egq60
```
<?php
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// allocate a large byte string of around 5 MB
$a = str_repeat("0", 5 * 1024 * 1024);
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// setting the memory limit lower than the current is accepted
ini_set("memory_limit", "3M");
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// further allocation beyond the limit
$b = str_repeat("0", 5 * 1024 * 1024);
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
```
--
Edit bug report at https://bugs.php.net/bug.php?id=81070&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81070&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81070&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81070&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81070&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81070&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81070&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81070&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81070&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81070&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81070&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81070&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81070&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81070&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81070&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81070&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81070&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81070&r=mysqlcfg
Thread (4 messages)
- pvandommelen at gmail dot com