php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26042 Memory usage
Submitted: 2003-10-30 10:41 UTC Modified: 2003-10-30 23:33 UTC
From: vsv3 at alu dot ua dot es Assigned:
Status: Closed Package: mcrypt related
PHP Version: 4CVS, 5CVS OS: Linux 2.4.22 Debian Woody
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vsv3 at alu dot ua dot es
New email:
PHP Version: OS:

 

 [2003-10-30 10:41 UTC] vsv3 at alu dot ua dot es
Description:
------------
When I use the functions for encrypt some data, the memory that PHP uses, doesn't get free. It gets more and more memory.

Reproduce code:
---------------
<?php
$key = '123456789012345678901234567890';
$iv  = '12345678';

$nVeces = 100000;
$n = 0;
$td = mcrypt_module_open( MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '' );
while( $n < $nVeces ) {
	$fichero = file_get_contents( "/tmp/hola" );

	mcrypt_generic_init( $td, $key, $iv );
	$fichero_enc = addslashes( mcrypt_generic($td, $textoPlano) );
	unset( $fichero_enc );

	if( isset($fichero_enc) ) echo "<b><h1>No pudimos destruir la variable</h1></b><br />";
	$n = $n + 1;
}
mcrypt_module_close( $td );
?>

Expected result:
----------------
A script that execute with a consume of less than 1MB of memory (with a file '/tmp/hola' of 1kB).

Actual result:
--------------
An script that consumes more than 100MB, or more. A similar script with other data, have been consumed more than 2000MB.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-30 18:06 UTC] jay@php.net
Looks like a leak starting in mcrypt_generic_init(). When 
mcrypt_generic_init() is called from PHP userland, it 
never gets deinit'd unless you explicitly call 
mcrypt_generic_deinit(). 
 
Perhaps mcrypt_generic_init() should check to see if the 
td has already been init'd and if so, deinit it first. 
Haven't looked too closely at the libmcrypt source yet to 
see the easiest way to do it.  
 
This is using libmcrypt 2.5.7 and an up-to-date 4_3.  
 
J 
 [2003-10-30 23:33 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.0, will be fixed in 4.X after 4.3.4 release.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 11:01:33 2024 UTC