Bug #77773 [NEW]: Unbuffered queries leak memory - MySQLi / mysqlnd

From: Date: Wed, 20 Mar 2019 15:58:19 +0000
Subject: Bug #77773 [NEW]: Unbuffered queries leak memory - MySQLi / mysqlnd
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220101@lists.php.net to get a copy of this message
From: alex at alex-at dot net Operating system: CentOS 7 PHP version: 7.3.3 Package: MySQLi related Bug Type: Bug Bug description:Unbuffered queries leak memory - MySQLi / mysqlnd Description: ------------ This is actually is a followup of #77308, because following up already closed bug is meaningless. Still present in 7.3.3 Some details of test run: --- 1. Versions (tried both ZTS and NTS, same results) #/opt/php71/bin/php -v PHP 7.1.27 (cli) (built: Mar 18 2019 13:00:22) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies # /opt/php72/bin/php -v PHP 7.2.16 (cli) (built: Mar 18 2019 13:03:57) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies # /opt/php73/bin/php -v PHP 7.3.3 (cli) (built: Mar 18 2019 13:07:58) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies --- 2. Top data for ~10 sec of script run 7.1: 112241 root 20 0 307892 13932 8396 R 100.0 0.2 0:11.82 /opt/php71/bin/php ./test.php 7.2: 111796 root 20 0 310480 14228 8460 R 99.7 0.2 0:10.41 /opt/php72/bin/php ./test.php 7.3: 110517 root 20 0 1148804 848480 8716 R 99.7 10.4 0:10.37 /opt/php73/bin/php ./test.php You can easily see RES size growing from stable 14M on PHP 7.1/7.2 to 840M+ on PHP 7.3. The script fails with out of memory error eventually (Allowed memory size of 1073741824 bytes exhausted (tried to allocate 16384 bytes) in /config/scripts/test.php on line 10) --- 3. Script excerpt (it's ultimately simple, but the query returns 11+ million rows) is provided as 'Test script' Test script: --------------- #!/opt/php73/bin/php <?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('memory_limit', '1G'); $db = new MySQLi('<server>', '<login>', '<password>', 'radius'); $res = $db->query('SELECT AcctSessionId AS sid, AcctUniqueId AS uid FROM radacct ORDER BY AcctSessionId, AcctUniqueId', MYSQLI_USE_RESULT); while (is_array($row = $res->fetch_assoc())); $res->free(); Expected result: ---------------- Memory does not leak Actual result: -------------- Memory leaks -- Edit bug report at https://bugs.php.net/bug.php?id=77773&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77773&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77773&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77773&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77773&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77773&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77773&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77773&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77773&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77773&r=support Expected behavior: https://bugs.php.net/fix.php?id=77773&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77773&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77773&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77773&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77773&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77773&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77773&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77773&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77773&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77773&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77773&r=mysqlcfg

« previous php.bugs (#220101) next »