Skip to content

Perl 5.40 errors: DBI dr handle cleared whilst still active during global destruction #171

@dlangille

Description

@dlangille

After moving from Perl 5.38 to Perl 5.40, errors such as this started to appear.

EDIT: The problem is also reproducible on Perl 5.42

DBI db handle 0x190cb2d3bb40 has 1 uncleared child handles during global destruction.
    dbih_clearcom (dbh 0x190cb2d3bb40, com 0x190cb23a8980, imp DBD::Pg::db):
       FLAGS 0x580111: COMSET Warn PrintError PrintWarn 
       PARENT DBI::dr=HASH(0x190cb2d3cd20)
       KIDS 1 (0 Active)

With the help of Perl/perl5#23306 I was able to create a small test script, which comes close to producing this.

[16:22 dev-ingress01 dvl ~/scripts] % perl perl5-issue-23306                
DONE
we are done
DBI dr handle 0x2e63aee41ae0 cleared whilst still active during global destruction.
    dbih_clearcom (drh 0x2e63aee41ae0, com 0x2e63ae4b12c0, imp DBD::Pg::dr):
       FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit 
       PARENT undef
       KIDS 0 (1 Active)
[16:26 dev-ingress01 dvl ~/scripts] % 

The script is:

#!/usr/bin/env perl

use strict;
use warnings;
use DBI;



my $dbh = DBI->connect("dbi:Pg:dbname=freshports.dev;host=pg03.example.org", "redacted", 'redaacted');

print "DONE\n";
exit 0;

sub sub1 {
    $dbh = "";
}

END {
#    $dbh->disconnect if $dbh;
#    $dbh = undef;
    print "we are done\n";
}

If either of the lines in END are uncommented, the error does not occur.

In my code, the problem is not reproducible. It seems to happen sometimes. For example, on three hosts running the same code and processing the same input, the error might appear on one, but not the other two. Sometimes on two, but not the third. It is not consistent and is rarely reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions