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";


PerlIO::Layer->find("Noisy", 1);
$ ./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

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 25 of 25 | next ›
Discussion Overview
groupperl5-porters @
postedMay 3, '16 at 6:34p
activeMay 5, '16 at 11:50a



site design / logo © 2018 Grokbase