Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DESTRUCT-time leak detectors cause warnings #299

Open
FGasper opened this issue Jun 6, 2022 · 0 comments
Open

DESTRUCT-time leak detectors cause warnings #299

FGasper opened this issue Jun 6, 2022 · 0 comments

Comments

@FGasper
Copy link
Contributor

FGasper commented Jun 6, 2022

#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::FailWarnings;

{
    my $thing = bless [], 'LeakDetector';
    is( $thing, $thing, 'I am I' );
}

done_testing;

# ----------------------------------------------------------------------

package LeakDetector;

sub DESTROY {
    warn "DESTROY at global destruction!\n" if ${^GLOBAL_PHASE} eq 'DESTRUCT';
}

If you run the above under Devel::Cover we see something like:

> perl -MDevel::Cover ref_bug.t
Devel::Cover 1.36: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
    /Devel/Cover[./]
Ignoring packages in:
    /Users/felipe/perl5/lib/perl5/darwin-thread-multi-2level
    /Users/felipe/perl5/lib/perl5
    /opt/local/lib/perl5/site_perl/5.28/darwin-thread-multi-2level
    /opt/local/lib/perl5/site_perl/5.28
    /opt/local/lib/perl5/vendor_perl/5.28/darwin-thread-multi-2level
    /opt/local/lib/perl5/vendor_perl/5.28
    /opt/local/lib/perl5/5.28/darwin-thread-multi-2level
    /opt/local/lib/perl5/5.28
ok 1 - I am I
1..1
Devel::Cover: Deleting old coverage for changed file ref_bug.t
Devel::Cover: getting BEGIN block coverage
Devel::Cover: 100% - 0s taken
Devel::Cover: getting CHECK block coverage
Devel::Cover: 100% - 0s taken
Devel::Cover: getting END/INIT block coverage
Devel::Cover: 100% - 0s taken
Devel::Cover: getting CV coverage
Devel::Cover: 100% - 0s taken
Devel::Cover: Writing coverage database to /Users/felipe/code/Devel--Cover/cover_db/runs/1654521279.80674.37036
--------- ------ ------ ------ ------ ------ ------ ------
File        stmt   bran   cond    sub    pod   time  total
--------- ------ ------ ------ ------ ------ ------ ------
ref_bug.t   94.4    0.0    n/a   80.0    n/a  100.0   84.0
Total       94.4    0.0    n/a   80.0    n/a  100.0   84.0
--------- ------ ------ ------ ------ ------ ------ ------


Use of uninitialized value $hid in hash element at /Users/felipe/perl5/lib/perl5/Test2/API.pm line 396 during global destruction.
Use of uninitialized value $hid in hash element at /Users/felipe/perl5/lib/perl5/Test2/API.pm line 492 during global destruction.
Use of uninitialized value $hid in hash element at /Users/felipe/perl5/lib/perl5/Test2/API.pm line 493 during global destruction.
Use of uninitialized value in array element at /Users/felipe/perl5/lib/perl5/Test/Builder.pm line 706 during global destruction.
	(in cleanup) 	(in cleanup)  at /Users/felipe/perl5/lib/perl5/Test/Builder.pm line 729 during global destruction.
	(in cleanup) 	(in cleanup)  at /Users/felipe/perl5/lib/perl5/Test2/API/Context.pm line 73 during global destruction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant