|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52249 Connection not closed on thrown exception, E_ERROR
Submitted: 2010-07-05 09:47 UTC Modified: 2013-02-18 00:34 UTC
From: dinumarina at gmail dot com Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: Irrelevant OS: CentOs
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dinumarina at gmail dot com
New email:
PHP Version: OS:


 [2010-07-05 09:47 UTC] dinumarina at gmail dot com
PHP version is 5.1.6 I haven't had the chance to run on newer versions but I suspect it's a persistent structural bug; What happens is MySQLi connection is not closed when script ends if it terminates due to a raised exception or an E_ERROR. This causes a number of problems from filling connection pool (mild) to blocking transactions (severe). The connection is never closed until reset by mysql server. For exceptions, there is the workaround of manually closing the connection in a default exception handler, but for E_ERROR I couldn't find any closing protocol. If this has been fixed in the later releases please be so kind to ignore this. However I suspect otherwise since I could find no discussions related to this. At the moment I don't have time to test with another release.

Test script:
throw new Exception();

Expected result:
When a script terminates (especially when crashed) all resources should be freed: all open handles, tcp connections, etc. I realize there is a problem with persistent connection handling, but a way should be found to clean up the mess; otherwise one script can trash the whole server by blocking transactions.

Actual result:
Connection lingers.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-05 10:18 UTC]
-Status: Open +Status: Feedback
 [2010-07-05 10:18 UTC]
Please try using this snapshot:
For Windows:
 [2010-07-05 11:39 UTC] dinumarina at gmail dot com
-Status: Feedback +Status: Open
 [2010-07-05 11:39 UTC] dinumarina at gmail dot com
Do you expect it will fix it or just for test? I'm really pressed with time.
 [2010-07-05 12:00 UTC]
-Status: Open +Status: Feedback
 [2010-07-05 12:00 UTC]
If you are in a hurry, then test it with a decent version (5.2.13 or 5.2.14RC2, 5.3.2 or 5.3.3RC2).
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 08:01:30 2024 UTC