php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42390 GMP functions exhausts memory
Submitted: 2007-08-22 21:39 UTC Modified: 2008-11-05 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: cbimax at gmail dot com Assigned:
Status: No Feedback Package: GNU MP related
PHP Version: 5.2.5 OS: Linux Gentoo K.2.6.20
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cbimax at gmail dot com
New email:
PHP Version: OS:

 

 [2007-08-22 21:39 UTC] cbimax at gmail dot com
Description:
------------
Any gmp_* function running on PHP 5.2.2-r1 (compiled with GMP extensions), throws after a few invokes "Fatal error: Allowed memory size of <varies from 7M to 8M> bytes exhausted (tried to allocate 16 bytes) in <file.php>". 

Reproduce code:
---------------
for( $i= 0; $i!= 100000; $i++ )
{
  $node = gmp_init( $i );
  $id = gmp_div( $node, '0x100000000' );

  $edge = gmp_and( $node, '0xffffffff' );
  $vert = gmp_div( $node, '0x1000' );
  $path = gmp_and( $node, '0x00ff' );

  $str_edge = gmp_strval( $edge );
  $str_vert = gmp_strval( $vert );
  $str_path = gmp_strval( $path );

  echo "Graph -> ($str_edge, $str_vert, $str_path) \n";
}



Expected result:
----------------
The iterated procedure runs on PHP 5.1.x (and PHP 5.0.x) near to 1 million times per call.

In this case, it's only runs 500 times and then drop the Fatal error.


Actual result:
--------------
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16 bytes) in quixtor/compute-graph-map.php on line 443 (actually line 443 isn't a gmp related function, but it is called under for() iteration which uses GMP functions).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-23 09:42 UTC] jani@php.net
I can not reproduce this using latest PHP 5.2.4-dev. 
So please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz

 [2007-12-02 14:16 UTC] cbimax at gmail dot com
Well, I tested against PHP 5.2.5 and it fails:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 12 bytes) in ./gmp-test.php on line 10

when trying to execute the example code.
 [2007-12-15 21:37 UTC] cbimax at gmail dot com
Now I install Gentoo from scratch, running on HP Proliant dual Xeon 3.6 (EM64T) 2GB RAM, with Linux Gentoo 2.6.22-r8 (64 bits)... so the example works, but if I increase to 1,000,000 iterations it flaws again with: 

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16 bytes) in /home/admin/gmp-test.php on line 6

No other services, nor heavy processes running...
 [2008-10-28 21:46 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-05 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC