php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17571 Memory leak in basic globals
Submitted: 2002-06-03 05:18 UTC Modified: 2002-10-10 15:56 UTC
From: tzikmund at iccc dot cz Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.1 OS: Redhat Linux 7.2
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tzikmund at iccc dot cz
New email:
PHP Version: OS:

 

 [2002-06-03 05:18 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 basic globals destructor:                      

There's original basic globals destructor source 
from PHP 4.2.1:                            

static void basic_globals_dtor(php_basic_globals *basic_globals_p TSRMLS_DC)
{
 	zend_hash_destroy(&BG(sm_protected_env_vars));
	if (BG(sm_allowed_env_vars)) {
		free(BG(sm_allowed_env_vars));
	}
#ifdef PHP_WIN32
	CoUninitialize();
#endif
}

There's an item called url_adapt_state_ex in the BG array which seems to
be no deallocated in the destructor. 

I've tried following modification:

static void basic_globals_dtor(php_basic_globals *basic_globals_p TSRMLS_DC)
{
 	zend_hash_destroy(&BG(sm_protected_env_vars));
	if (BG(sm_allowed_env_vars)) {
		free(BG(sm_allowed_env_vars));
	}

        if (BG(url_adapt_state_ex).tags)
	{
       	 zend_hash_destroy(BG(url_adapt_state_ex).tags);
         free(BG(url_adapt_state_ex).tags);
	}

#ifdef PHP_WIN32
	CoUninitialize();
#endif
}
 
I don't know if my modification is clean, but it seems to solve the problem.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-03 05:21 UTC] mfischer@php.net
Ops :) Please try with HEAD.
 [2002-06-03 06:16 UTC] tzikmund at iccc dot cz
I've tried the latest CVS version and it seems the problem is still here.
 [2002-10-07 22:08 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-10-10 15:56 UTC] tzikmund at iccc dot cz
It seems to be all right in the new version.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 18:00:03 2025 UTC