Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32422 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35743 invoked by uid 1010); 23 Sep 2007 09:59:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35727 invoked from network); 23 Sep 2007 09:59:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2007 09:59:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=alexandra@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alexandra@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: alexandra@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:54778] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/A1-17254-7F836F64 for ; Sun, 23 Sep 2007 05:59:22 -0400 Received: from [10.1.3.7] ([10.1.3.7]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 23 Sep 2007 12:03:03 +0200 Message-ID: <46F638F5.9030008@zend.com> Date: Sun, 23 Sep 2007 11:59:17 +0200 User-Agent: Icedove 1.5.0.8 (X11/20061129) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------070506070701060706000500" X-OriginalArrivalTime: 23 Sep 2007 10:03:03.0099 (UTC) FILETIME=[EDF680B0:01C7FDC8] Subject: [Fwd: bug in odbc extension http://bugs.php.net/bug.php?id=37527] From: alexandra@zend.com ("Alexandra S.") --------------070506070701060706000500 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I am attaching here a patch for this bug. Please review it. -------- Original Message -------- Subject: bug in odbc extension http://bugs.php.net/bug.php?id=37527 Date: Tue, 18 Sep 2007 15:29:23 +0200 From: Alexandra S. To: internals@lists.php.net Hi, I have been trying to work on this bug. The problem here is in this scenario: 1. odbc connection is established. 2. odbc connection is closed. 3. trying to do a request (example: odbc_exec) to the database using the closed connection -> crash. As far as I can understand from reading the odbc_exec() function, ZEND_FETCH_RESOURCE2 should return false,, so we do not advance to the SQLAllocStmt call that crashes. I checked with php 5.2.4 on both Linux and Windows and ZEND_FETCH_RESOURCE2 does not return false. The reason for it is in the odbc_close function - for(i = 1; i < nument; i++){ ptr = zend_list_find(i, &type); if(ptr && (type == le_result)){ res = (odbc_result *)ptr; if(res->conn_ptr == conn){ zend_list_delete(i); } } } Here only the previous statements of this connection are deleted and not the connection itself. In the odbc_close_all function all the statements are deleted, and then all the connections. I suggest to add the deletion of the connection itself to the odbc_close function - so the ZEND_FETCH_RESOURCE2 check will actually work. The situation now is that check do not work and we try all the time to call SQL actions with no existent connections. Example for possible solution: for(i = 1; i < nument; i++){ ptr = zend_list_find(i, &type); if(ptr && (type == le_result)){ res = (odbc_result *)ptr; if(res->conn_ptr == conn){ zend_list_delete(i); } } if(ptr && (type == (is_pconn?le_pconn:le_conn))){ res = (odbc_result *)ptr; if(res == conn){ zend_list_delete(i); } } } Alexandra Shpindovsky --------------070506070701060706000500 Content-Type: text/plain; name="patch1.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch1.txt" --- php_odbc.c 2007-03-13 02:04:38.000000000 +0200 +++ php_odbc.c 2007-09-20 09:50:49.000000000 +0200 @@ -2415,6 +2415,12 @@ zend_list_delete(i); } } + if(ptr && (type == (is_pconn?le_pconn:le_conn))){ + res = (odbc_connection *)ptr; + if(res == conn){ + zend_list_delete(i); + } + } } zend_list_delete(Z_LVAL_PP(pv_conn)); --------------070506070701060706000500--