#23187 [Opn->Csd]: Memory leak in sybase_connect/sybase_pconnect
| From: | iliaa@php.net | Date: | Tue, 15 Apr 2003 01:00:43 +0000 |
| Subject: | #23187 [Opn->Csd]: Memory leak in sybase_connect/sybase_pconnect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37672@lists.php.net to get a copy of this message | ||
ID: 23187
Updated by: iliaa@php.net
Reported By: fukusaka at xa2 dot so-net dot ne dot jp
-Status: Open
+Status: Closed
Bug Type: Sybase (dblib) related
Operating System: Linux 2.4.18 (debian/woody)
PHP Version: 4CVS-2003-04-13 (stable)
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2003-04-13 09:24:27] fukusaka at xa2 dot so-net dot ne dot jp
There is a leak of execution of free of LOGINREC and DBPROCESS
inside sybase_connet/sybase_pconnet of Sybase (dblib).
This leak occurs, only when it is a system at the high load time,
is that the number of connection of ASE exceeds several times from
usual,
and causes the error with the scarce reproducibility of a sybase
function.
A patch like this should work:
Index: php_sybase_db.c
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v
retrieving revision 1.38.2.5
diff -u -r1.38.2.5 php_sybase_db.c
--- php_sybase_db.c 31 Dec 2002 16:35:36 -0000 1.38.2.5
+++ php_sybase_db.c 13 Apr 2003 13:13:21 -0000
@@ -478,6 +478,7 @@
php_sybase_module.num_persistent++;
php_sybase_module.num_links++;
} else { /* we do */
+ dbloginfree(sybase.login);
if (Z_TYPE_P(le) != php_sybase_module.le_plink) {
php_error(E_WARNING,"Sybase: Hashed persistent link is not a
Sybase link!");
efree(hashed_details);
@@ -487,7 +488,8 @@
sybase_ptr = (sybase_link *) le->ptr;
/* test that the link hasn't died */
if (DBDEAD(sybase_ptr->link)==TRUE) {
- if
((sybase_ptr->link=PHP_SYBASE_DBOPEN(sybase_ptr->login,host))==FAIL) {
+ dbclose(sybase_ptr->link);
+ if
((sybase_ptr->link=PHP_SYBASE_DBOPEN(sybase_ptr->login,host))==NULL) {
/*php_error(E_WARNING,"Sybase: Link to server lost, unable to
reconnect");*/
zend_hash_del(&EG(persistent_list), hashed_details,
hashed_details_length+1);
efree(hashed_details);
@@ -514,6 +516,7 @@
int type,link;
void *ptr;
+ dbloginfree(sybase.login);
if (Z_TYPE_P(index_ptr) != le_index_ptr) {
efree(hashed_details);
RETURN_FALSE;
@@ -532,12 +535,14 @@
if (php_sybase_module.max_links!=-1 &&
php_sybase_module.num_links>=php_sybase_module.max_links) {
php_error(E_WARNING,"Sybase: Too many open links
(%d)",php_sybase_module.num_links);
efree(hashed_details);
+ dbloginfree(sybase.login);
RETURN_FALSE;
}
if ((sybase.link=PHP_SYBASE_DBOPEN(sybase.login,host))==NULL) {
/*php_error(E_WARNING,"Sybase: Unable to connect to server:
%s",sybase_error(sybase));*/
efree(hashed_details);
+ dbloginfree(sybase.login);
RETURN_FALSE;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23187&edit=1