php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45432 PDO: persistent connection leak
Submitted: 2008-07-04 17:39 UTC Modified: 2009-02-13 02:23 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: uwendel at mysql dot com Assigned: felipe (profile)
Status: Closed Package: PDO related
PHP Version: 5.3CVS-2008-07-04 (CVS) OS: Linux 64bit
Private report: No CVE-ID: None
 [2008-07-04 17:39 UTC] uwendel at mysql dot com
Description:
------------
Creating a persistent connection handle and assigning a new persistent connection to the same handle (variable) causes a leak.

$db = new PDO(...)
$db = new PDO(...) <--- leak


My PHP 5.3 CVS snapshot is a little older than 04.07.2008, anyway.
nixnutz@ulflinux:~/php53> sapi/cli/php -v
PHP 5.3.0-dev (cli) (built: Jul  3 2008 16:20:01) (DEBUG)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies


Reproduce code:
---------------
nixnutz@ulflinux:~/php53> valgrind sapi/cli/php -r '$db = new 

PDO("sqlite:/tmp/foo", NULL, NULL, array(PDO::ATTR_PERSISTENT => true)); $db = new PDO("sqlite:/tmp/foo", NULL, NULL, array(PDO::ATTR_PERSISTENT => true));'
==32328== Memcheck, a memory error detector.
==32328== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==32328== Using LibVEX rev 1804, a library for dynamic binary translation.
==32328== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==32328== Using valgrind-3.3.0, a dynamic binary instrumentation framework.
==32328== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==32328== For more details, rerun with: -v
[Fri Jul  4 19:35:02 2008]  Script:  '-'
/home/nixnutz/php53/ext/pdo/pdo_dbh.c(1513) :  Freeing 0x0655C3C8 (72 bytes), script=-
[Fri Jul  4 19:35:02 2008]  Script:  '-'
/home/nixnutz/php53/ext/pdo/pdo_dbh.c(1514) :  Freeing 0x0655C468 (64 bytes), script=-
/home/nixnutz/php53/Zend/zend_alloc.c(2374) : Actual location (location was relayed)
=== Total 2 memory leaks detected ===
==32328==
==32328== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==32328== malloc/free: in use at exit: 91,869 bytes in 137 blocks.
==32328== malloc/free: 11,910 allocs, 11,773 frees, 3,125,629 bytes allocated.
==32328== For counts of detected errors, rerun with: -v
==32328== searching for pointers to 137 not-freed blocks.
==32328== checked 558,296 bytes.
==32328==
==32328== LEAK SUMMARY:
==32328==    definitely lost: 11,325 bytes in 128 blocks.
==32328==      possibly lost: 456 bytes in 6 blocks.
==32328==    still reachable: 80,088 bytes in 3 blocks.
==32328==         suppressed: 0 bytes in 0 blocks.
==32328== Rerun with --leak-check=full to see details of leaked memory.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-29 23:38 UTC] felipe@php.net
That is related to #43831, the cached dbh have your data changed disregarding the dbh->ce, and the alloced 'properties' isn't freed.
 [2009-02-13 02:23 UTC] felipe@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC