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
Nicholas Clark
May 5, 2016 11:50
that missing test case (was Re: revert MG consting (Coro breakage)for 5.24?)
Message ID:
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/
#!/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";


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

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

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About