php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23187 Memory leak in sybase_connect/sybase_pconnect
Submitted: 2003-04-13 09:24 UTC Modified: 2003-04-14 20:00 UTC
From: fukusaka at xa2 dot so-net dot ne dot jp Assigned:
Status: Closed Package: Sybase (dblib) related
PHP Version: 4CVS-2003-04-13 (stable) OS: Linux 2.4.18 (debian/woody)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fukusaka at xa2 dot so-net dot ne dot jp
New email:
PHP Version: OS:

 

 [2003-04-13 09:24 UTC] 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;
 		}
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-14 20:00 UTC] iliaa@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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 02:01:29 2024 UTC