Skip Menu |
 

This queue is for tickets about the DBD-mysql CPAN distribution.

Report information
The Basics
Id: 83051
Status: resolved
Priority: 0/
Queue: DBD-mysql

People
Owner: CAPTTOFU [...] cpan.org
Requestors: vasek.balcar [...] spolecne.cz
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 4.033_03



Subject: Access to $sth->{ParamValues} leaks
Download (untitled) / with headers
text/plain 554b
Seems like library returns the wrong refcount? Forget to release pvhv? if (strEQ(key, "ParamValues")) { HV *pvhv= newHV(); if (DBIc_NUM_PARAMS(imp_sth)) { int n; char key[100]; I32 keylen; for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++) { keylen= sprintf(key, "%d", n); hv_store(pvhv, key, keylen, newSVsv(imp_sth->params[n].value), 0); } } retsv= newRV_noinc((SV*)pvhv); }
Subject: test-leaky-mysql.pl
Download test-leaky-mysql.pl
text/x-perl 544b
#!/usr/bin/perl -w use strict; use DBI; use Data::Dumper; # CREATE DATABASE test; # USE test; # CREATE TABLE `employee` ( # `id` int(11) unsigned NOT NULL AUTO_INCREMENT, # PRIMARY KEY (`id`) # ) ENGINE=InnoDB DEFAULT CHARSET=latin1; my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","root",undef); my $sth = $dbh->prepare("SELECT * FROM employee WHERE id = ?"); while (1) { $sth->execute('123456789'); my $row = $sth->fetchrow_hashref(); print Data::Dumper->Dump([$sth->{ParamValues}]); $sth->finish(); }
Download (untitled) / with headers
text/plain 764b
On Wed Jan 30 11:03:09 2013, VASEK wrote: Show quoted text
> Seems like library returns the wrong refcount? Forget to release pvhv? > > if (strEQ(key, "ParamValues")) > { > HV *pvhv= newHV(); > if (DBIc_NUM_PARAMS(imp_sth)) > { > int n; > char key[100]; > I32 keylen; > for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++) > { > keylen= sprintf(key, "%d", n); > hv_store(pvhv, key, > keylen, newSVsv(imp_sth->params[n].value), 0); > } > } > retsv= newRV_noinc((SV*)pvhv); > }
I confirm the issue. It seems to be enough to "mortilize" the return value, i.e. do "retsv= sv_2mortal(newRV_noinc((SV*)pvhv))".
Subject: [rt.cpan.org #83051]
Date: Thu, 18 Apr 2013 18:00:58 +0300
To: bug-DBD-mysql [...] rt.cpan.org
From: Alexander Kubrack <kubrack [...] gmail.com>
Download (untitled) / with headers
text/plain 394b
I confirm it too, and used the patch listed below for fix it locally. --- /usr/ports/databases/p5-DBD-mysql/work/DBD-mysql-4.021/dbdimp.c 2012-04-28 16:48:56.000000000 +0300 +++ dbdimp.c 2013-04-18 17:03:53.000000000 +0300 @@ -4441,7 +4441,7 @@ keylen, newSVsv(imp_sth->params[n].value), 0); } } - retsv= newRV_noinc((SV*)pvhv); + retsv= sv_2mortal(newRV_noinc((SV*)pvhv)); } break; case 'S':
RT-Send-CC: CAPTTOFU [...] cpan.org
Can you please look at this one?
Download (untitled) / with headers
text/plain 263b
Hi Patrick, We have just "celebrated" 2nd year from the last activity about this bug and it still seems to be unfixed, despite the proposed patch in this TT seems to fix the leak ... Please, any chance you can take a look? Anything I can help with? -- vasek
Download (untitled) / with headers
text/plain 640b
On Mon Oct 12 08:51:31 2015, VASEK wrote: Show quoted text
> > We have just "celebrated" 2nd year from the last activity about this > bug and it still seems to be unfixed, despite the proposed patch in > this TT seems to fix the leak ... > > Please, any chance you can take a look? Anything I can help with?
Thanks for pinging the bug report. I just applied the patch to DBD::mysql here: https://github.com/perl5-dbi/DBD-mysql/commit/7a09e8a8c7162fdbb4a043602f4e0f81c2f7c5aa If you'd like to contribute some code, adding a unit test would be nice :D You can add it here in the RT ticket or send it as a pull request to the above git repo. -- Michiel


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.