|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-05-24 22:56 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2015-05-24 22:56 UTC] nikic@php.net
[2015-05-25 14:54 UTC] info at daniel-marschall dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Description: ------------ Given is following CLI script, which will do a "for" loop for BigIntegers (gmp). I iterate $i from 0 to 999999999999999999 . I see 4 problems: 1) There is no possibility to increase a GMP number without re-creating it using gmp_add() . 2) On a 64-bit OS, the max handle pool is still an unsigned 32 bit int (see below)??? 3) The handle pool counter does not reset when variables are freed, therefore an integer overflow happens. 4) there is no possibility to free a gmp resource. I assume that it is done automatically, since there is no gmp_free(). Test script: --------------- #!/usr/bin/php <?php $max = gmp_init("999999999999999999"); $i = gmp_init(0); while ((gmp_cmp($i, $max) == -1)) { $i = gmp_add($i, 1); } Expected result: ---------------- Since $i is re-assigned (and the old instance of the gmp-object is freed therefore), there should be neither a memory overflow, nor anything else failing. Actual result: -------------- [after a very long waiting time, of course!] PHP Warning: gmp_cmp(): -2147483648 is not a valid GMP integer resource in .../phpbug.php on line 7 PHP Stack trace: PHP 1. {main}() .../phpbug.php:0 PHP 2. gmp_cmp() .../phpbug.php:7 Warning: gmp_cmp(): -2147483648 is not a valid GMP integer resource in .../phpbug.php on line 7 Call Stack: 0.0001 226000 1. {main}() .../phpbug.php:0 4309.1840 227048 2. gmp_cmp() .../phpbug.php:7