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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1359561788-11461-4"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 554
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
MIME-Version: 1.0
Content-Type: text/x-perl-script; name="test-leaky-mysql.pl"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="test-leaky-mysql.pl"
Content-Transfer-Encoding: binary
Content-Length: 544
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(); }
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: API
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.11-27541-1366287428-1869.0-0-0 [...] rt.cpan.org>
Message-ID: <rt-4.0.11-27541-1366287428-974.83051-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 764
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))".
From kubrack [...] gmail.com Thu Apr 18 11: 01:15 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-6.219 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_NEUTRAL=0.779] autolearn=ham
X-Spam-Flag: NO
X-RT-Interface: API
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.229.150.199 with SMTP id z7mr1134841qcv.25.1366297258304; Thu, 18 Apr 2013 08:00:58 -0700 (PDT)
Message-ID: <CAAzuG--Pc--zg1jLR1wWpEiiKkzmqH7uLGMc+nbGDhhudyan7Q [...] mail.gmail.com>
Content-Type: multipart/alternative; boundary="e89a8f6469dfbd47f404daa3de3d"
X-Spam-Score: -6.219
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id AAEB9240807 for <cpan-bug+DBD-mysql [...] hipster.bestpractical.com>; Thu, 18 Apr 2013 11:01:15 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v2dqqnvTv7wA for <cpan-bug+DBD-mysql [...] hipster.bestpractical.com>; Thu, 18 Apr 2013 11:01:10 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 64F3824088A for <bug-DBD-mysql [...] rt.cpan.org>; Thu, 18 Apr 2013 11:01:10 -0400 (EDT)
Received: (qmail 9782 invoked by uid 103); 18 Apr 2013 15:01:09 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 18 Apr 2013 15:01:09 -0000
Received: from mail-qc0-f177.google.com (HELO mail-qc0-f177.google.com) (209.85.216.177) by 16.mx.develooper.com (qpsmtpd/0.84/v0.84-167-g4ed6cab) with ESMTP; Thu, 18 Apr 2013 08:01:01 -0700
Received: by mail-qc0-f177.google.com with SMTP id u28so1374787qcs.8 for <bug-DBD-mysql [...] rt.cpan.org>; Thu, 18 Apr 2013 08:00:58 -0700 (PDT)
Received: by 10.49.29.197 with HTTP; Thu, 18 Apr 2013 08:00:58 -0700 (PDT)
Delivered-To: cpan-bug+DBD-mysql [...] hipster.bestpractical.com
Subject: [rt.cpan.org #83051]
Return-Path: <kubrack [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=QPnQoUQ8TE+zmBz+wjelZSpvrcVGuOKLTLBfREt0yyM=; b=BYyEdN4ZDK3zFXzJwp4AubwphQbR/bt+EexWFl6LNCumY7oIcLKJwpvOrosl7P0WnN jDcBKHZNDzb51RNhZwUjh+YM/hDxglj/wqmNZSav0zB02DSYzGz0z3bFhcdAtED24QJF wqAO0F6dsrRr6Dpr3zR6Azdo+95hP5TRhMX0vWZ8CNBQ1ktA8BlsJ864KlSndtst7nnj C+v6jIOPNyuQWHOOszH2GKCS++5/NoBQ6UkMDkdmWjGFFeMah+jxCa2yWicwuzvlHp/A gz5J33Xz46gbJKxEUFKmTrkmRPCCOeWVUsXeYCSrG569Kb6NszXXgE0d0WjLyeliwrUK VwfQ==
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+DBD-mysql [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbd-mysql
Date: Thu, 18 Apr 2013 18:00:58 +0300
X-Spam-Level:
To: bug-DBD-mysql [...] rt.cpan.org
From: Alexander Kubrack <kubrack [...] gmail.com>
RT-Message-ID: <rt-4.0.11-12091-1366297276-1656.83051-0-0 [...] rt.cpan.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 394
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':
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 550
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.16-12874-1381427534-1796.83051-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
RT-Send-CC: CAPTTOFU [...] cpan.org
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 32
Can you please look at this one?
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-12874-1381427534-1796.83051-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.16-12874-1381427534-1796.83051-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-12446-1444654291-585.83051-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 263
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
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-12446-1444654291-585.83051-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.16-12874-1381427534-1796.83051-0-0 [...] rt.cpan.org> <rt-4.0.18-12446-1444654291-585.83051-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-16857-1444670426-825.83051-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 640
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.