php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17570 Memory leak
Submitted: 2002-06-03 05:02 UTC Modified: 2002-09-25 09:01 UTC
From: tzikmund at iccc dot cz Assigned:
Status: Closed Package: Regexps related
PHP Version: 4.1.2 OS: Redhat Linux 7.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 44 = ?
Subscribe to this entry?

 
 [2002-06-03 05:02 UTC] tzikmund at iccc dot cz
I'm trying to run PHP in my own multithreaded environment.
Memory leaks are critical for my application.

I've tried to track the leaks down using memprof and I think
I've found a leak in the initialization of globals in standard regex
extension.

There's original module initialization taken
from PHP 4.2.1 sources (ext/standard/reg.c):

PHP_MINIT_FUNCTION(regex)
{
#ifdef ZTS
	ts_allocate_id(&reg_globals_id,
         sizeof(php_reg_globals),
        (ts_allocate_ctor) php_reg_init_globals, NULL);
#else
     	php_reg_init_globals(&reg_globals TSRMLS_CC);
#endif

      	return SUCCESS;
}

There's no destructor routine registered for the globals for thread-safe version of PHP.

I've tried to correct it writing destructor routine, there's the modified source:

static void php_reg_destroy_globals(php_reg_globals *reg_globals TSRMLS_DC)
{
 	zend_hash_destroy(&reg_globals->ht_rc);
}

PHP_MINIT_FUNCTION(regex)
{
#ifdef ZTS
        ts_allocate_id(&reg_globals_id,     sizeof(php_reg_globals),
                (ts_allocate_ctor) php_reg_init_globals,
                (ts_allocate_dtor) php_reg_destroy_globals);
#else
        php_reg_init_globals(&reg_globals TSRMLS_CC);
#endif
}

I'm not sure if my modification is clean, but it seems to solve the leak problem.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-03 05:07 UTC] tzikmund at iccc dot cz
The problem is still present in 4.2.1
 [2002-06-03 05:10 UTC] mfischer@php.net
Can you verify against HEAD if this problem is still there?
 [2002-06-03 06:15 UTC] tzikmund at iccc dot cz
I've tried the latest CVS version and it seems the problem is still here.
 [2002-06-17 19:02 UTC] sniper@php.net
Please try with this snapshot:

http://snaps.php.net/php4-latest.tar.gz

 [2002-06-18 11:59 UTC] tzikmund at iccc dot cz
I've tried the snapshot but situation is the same - the module
leaks 32 bytes every init/shutdown cycle.
 [2002-09-25 08:31 UTC] sniper@php.net
Assigned to Andrei per his request.

 [2002-09-25 08:56 UTC] andrei@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.


 [2002-09-25 09:01 UTC] sander@php.net
Fixed -> closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 08:01:30 2024 UTC