Bug #66859 BDB::mysql connect memory leak
Submitted: 18 Sep 2012 15:11 Modified: 6 Nov 2012 20:07
Reporter: Carlos Velasco Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S2 (Serious)
Version:4.022 OS:Linux
Assigned to: CPU Architecture:Any

[18 Sep 2012 15:11] Carlos Velasco
Description:
DBD::mysql leaks memory when using connect

Seems related to bug #60531 but I am seeing this with good password.

How to repeat:
Perl is 5.16.1
DBD::mysql is 4.022
DBI is 1.622
mysql is mysql-5.5.27.tar.gz

Use this perl script:

#!/usr/bin/perl

use Devel::Leak;

use DBI;
use DBD::mysql;

my $DLcount;
my $DLhandle;
my $con;

my $con = DBI->connect('DBI:mysql:database=test;host=127.0.0.1', 'root', '', {PrintError => 0,PrintWarn=>0});

$DLcount = Devel::Leak::NoteSV($DLhandle);
print "PRE 1 count: $DLcount\n";

undef $con;
$con = DBI->connect('DBI:mysql:database=test;host=127.0.0.1', 'root', '', {PrintError => 0,PrintWarn=>0});

$DLcount = Devel::Leak::NoteSV($DLhandle);
print "POST 1 count: $DLcount\n";

$DLcount = Devel::Leak::NoteSV($DLhandle);
print "PRE 2 count: $DLcount\n";

undef $con;
$con = DBI->connect('DBI:mysql:database=test;host=127.0.0.1', 'root', '', {PrintError => 0,PrintWarn=>0});

$DLcount = Devel::Leak::CheckSV($DLhandle);
print "POST 2 count: $DLcount\n";

Output shows:

# perl test.pl 
PRE 1 count: 12777
POST 1 count: 12778
PRE 2 count: 12778
new 0x7cce08 : SV = NULL(0x0) at 0x7cce08
  REFCNT = 1
  FLAGS = (PADSTALE,PADMY)
new 0x743250 : SV = PVAV(0x8f38e8) at 0x743250
  REFCNT = 1
  FLAGS = (PADSTALE,PADMY)
  ARRAY = 0x0
  FILL = -1
  MAX = -1
  ARYLEN = 0x0
  FLAGS = (REAL)
new 0x743b98 : SV = NULL(0x0) at 0x743b98
  REFCNT = 1
  FLAGS = (PADSTALE,PADMY)
old (1):
 0 SV = UNKNOWN(0xff) (0x743b80) at 0x7435c8
  REFCNT = 0
  FLAGS = ()
old (1):
 0 SV = UNKNOWN(0xff) (0x7435c8) at 0x7430a0
  REFCNT = 0
  FLAGS = ()
POST 2 count: 12779
[18 Sep 2012 15:39] Carlos Velasco
But DBD::mysql leaks test shows ok

# SLOW_TESTS=1 make test
PERL_DL_NONLAZY=1 /usr/bin/perl-64 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .................. ok   
...
t/60leaks.t ................. ok
[18 Sep 2012 18:12] Carlos Velasco
It seems this problem has been there for long long ago:

https://bugs.launchpad.net/ubuntu/+source/libdbd-mysql-perl/+bug/51746
[6 Nov 2012 20:07] Sveta Smirnova
Thank you for the report.

We don't work on DBD::mysql bugs anymore. All its bugs should go to CPAN: https://rt.cpan.org/Public/Dist/Display.html?Name=DBD-mysql

I re-submitted your report to https://rt.cpan.org/Public/Bug/Display.html?id=80669
Please subscribe to the new report on CPAN and work with DBD::mysql developers in case if they need additional details.