php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42509 GMP without gmp_init eats memory
Submitted: 2007-09-01 17:02 UTC Modified: 2012-05-24 11:09 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: pvqmhulilymtw at gmail dot com Assigned: stas (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.4 OS: Linux
Private report: No CVE-ID: None
 [2007-09-01 17:02 UTC] pvqmhulilymtw at gmail dot com
Description:
------------
Various GMP Functions eat memory, when not called directly with integers or strings instead of gmp resources.

Reproduce code:
---------------
$a='1234';
for($i=0;$i<200000;$i++) {
  $c=gmp_add(gmp_init($a),gmp_init($a));
}
echo memory_get_usage() . "?\n";
for($i=0;$i<200000;$i++) {
  $c=gmp_add($a,$a);
}
echo memory_get_usage() . "?\n";


Expected result:
----------------
Both memory_get_usage() should show nearly the same values.

Actual result:
--------------
1732656?    // ~ 2 MB
43809696?   // ~ 43 MB


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-03 10:47 UTC] jani@php.net
[jani@localhost php_5_2]$ sapi/cli/php t.php 
79768
99792024
[jani@localhost php_5_2]$ USE_ZEND_ALLOC=0 sapi/cli/php t.php 
8236
8236

 [2007-09-03 14:25 UTC] nlopess@php.net
Stas: what do you think about this patch:
http://web.ist.utl.pt/nuno.lopes/php_gmp_bug42509.txt
 [2007-11-01 00:48 UTC] stas@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3 branch. 
 [2012-05-23 00:19 UTC] azrzrqlilylrw at gmail dot com
vNjlttFilx <a href="http://www.jincheng.com/p90x.html">p90x work out</a> eMtbbmTyrd http://www.jincheng.com/p90x.html
 [2012-05-23 00:19 UTC] azrzrqlilylrw at gmail dot com
-: thomas.hebinck@digionline.de +: azrzrqlilylrw at gmail dot com -Package: Math related +Package: *General Issues
 [2012-05-24 11:09 UTC] pvqmhulilymtw at gmail dot com
-: azrzrqlilylrw@gmail.com +: pvqmhulilymtw at gmail dot com
 [2012-05-24 11:09 UTC] pvqmhulilymtw at gmail dot com
Zmef http://saclouisvuitton.webnode.fr/ Kzyl <a href="http://louisvuittonsacpascher.webnode.fr/">louis vuitton pas cher</a>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 20:01:35 2024 UTC