#23187 [NEW]: Memory leak in sybase_connect/sybase_pconnect

From: Date: Sun, 13 Apr 2003 14:24:27 +0000
Subject: #23187 [NEW]: Memory leak in sybase_connect/sybase_pconnect
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37611@lists.php.net to get a copy of this message
From: fukusaka at xa2 dot so-net dot ne dot jp Operating system: Linux 2.4.18 (debian/woody) PHP version: 4CVS-2003-04-13 (stable) PHP Bug Type: Sybase (dblib) related Bug description: Memory leak in sybase_connect/sybase_pconnect 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 bug report at http://bugs.php.net/?id=23187&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23187&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23187&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23187&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23187&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23187&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23187&r=support Expected behavior: http://bugs.php.net/fix.php?id=23187&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23187&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23187&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23187&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23187&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23187&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23187&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23187&r=gnused

« previous php.bugs (#37611) next »