develooper Front page | perl.perl5.porters | Postings from May 2016

that missing test case (was Re: revert MG consting (Coro breakage)for 5.24?)

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
May 5, 2016 11:50
Subject:
that missing test case (was Re: revert MG consting (Coro breakage)for 5.24?)
Message ID:
20160505114931.GS2048@ceres.etla.org
On Wed, May 04, 2016 at 11:43:45AM +0100, Nicholas Clark wrote:

> On the assumption that this fixes the actual problems that Coro hit,
> short of test cases to demonstrate otherwise.

I suspect that *this* is the bug that Coro hit.

For $whatever reason, PerlIO_find_layer() chooses to silence all warnings,
and implements this by localising PL_warnhook and then assigning a no-op sub
to it. The problem is that this isn't reflected in %SIG, so when Perl-space
code localises $SIG{__WARN__}, the previous value of $SIG{__WARN__} is
stored on the scope stack as the thing to write back at scope exit:


$ cat ~/test/via.pl
#!/usr/bin/perl -w
use strict;

unshift @INC, sub {
    return undef unless caller eq "main";
    return \<<'EOP';

print STDERR "This code is being called\n";

warn "My errors are eaten";

{
    local $SIG{__WARN__} = sub {
        my $message = shift;
        chomp $message;
        print STDERR "Warning you about '$message'\n";
    };
    warn "Christmas";
}

warn "This error message should still be eaten";

EOP
};

PerlIO::Layer->find("Noisy", 1);
__END__
$ ./perl -Ilib ~/test/via.pl 
This code is being called
Warning you about 'Christmas at /loader/0xb99c00/PerlIO.pm line 12.'
This error message should still be eaten at /loader/0xb99c00/PerlIO.pm line 15.


Remove the local $SIG{__WARN__} and that last warning is correctly suppressed.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About