Bug #17570: Memory leak
| From: | tzikmund at iccc dot cz | Date: | Mon, 03 Jun 2002 09:02:52 +0000 |
| Subject: | Bug #17570: Memory leak | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-9278@lists.php.net to get a copy of this message | ||
From: tzikmund@iccc.cz
Operating system: Redhat Linux 7.2
PHP version: 4.1.2
PHP Bug Type: *Regular Expressions
Bug description: Memory leak
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(®_globals_id,
sizeof(php_reg_globals),
(ts_allocate_ctor) php_reg_init_globals, NULL);
#else
php_reg_init_globals(®_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(®_globals->ht_rc);
}
PHP_MINIT_FUNCTION(regex)
{
#ifdef ZTS
ts_allocate_id(®_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(®_globals TSRMLS_CC);
#endif
}
I'm not sure if my modification is clean, but it seems to solve the leak
problem.
--
Edit bug report at http://bugs.php.net/?id=17570&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17570&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17570&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17570&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17570&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17570&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17570&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17570&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17570&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17570&r=globals