Subject: | circular reference in DBI::DBD::SqlEngine::TieTables |
Date: | Fri, 15 Jun 2018 13:46:32 +0100 |
To: | bug-DBI [...] rt.cpan.org |
From: | Dave Mitchell <davem [...] iabyn.com> |
While debugging an issue with DBD::CSV and/or perl:
https://rt.perl.org/Ticket/Display.html?id=133270
I spotted code in DBI::DBD::SqlEngine::TieTables which appears to
be creating a circular reference, and thus leaking.
DBI::DBD::SqlEngine::TieTables::TIEHASH() creates a tie object hash,
one of whose entries is a reference back to the $dbh handle.
I don't understand this code well enough to be 100% certain its a leak,
but it sure looks like a weaken() is in order.
The following code definitely leaks, although that may be in part due to
a bug in Text::CSV_XS which I have reported separately:
(it requires editing 'f_dir' to point to an untarred DBD-CSV-0.53
directory)
use strict;
use warnings;
use DBI;
while (1) {
my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
f_schema => undef,
f_dir => '/home/davem/tmp-nobackup/dbd-csv-free/DBD-CSV-0.53/t',
f_dir_search => [],
f_ext => ".csv/r",
f_lock => 2,
f_encoding => "utf8",
csv_auto_diag => 0,
RaiseError => 1,
PrintError => 1,
FetchHashKeyName => "NAME_lc",
}) or die "$DBI::errstr\n" || $DBI::errstr;
}
--
Art is anything that has a label (especially if the label is "untitled 1")