develooper Front page | perl.perl5.porters | Postings from September 2012

[perl #70001] interpreter crash with IO::Tee

Thread Next
James E Keenan via RT
September 1, 2012 10:03
[perl #70001] interpreter crash with IO::Tee
Message ID:
On Sat Sep 01 06:15:54 2012, dom wrote:
> On Wed Nov 11 03:27:26 2009, jackyf wrote:
> > Срд. Ноя. 11 02:48:32 2009, alecthegeek писал:
> > > Unfortunately IO::Tee is not a part of Perl 10.1 core and so we 
> cannot
> > > address this issue.
> > Um? So the interpreter crash with _Perl-only_ code is not a core
> > problem? I cannot agree with it.
> Sounds like a reasonable concern; re-opening.

When you read both the original Debian bug ticket and try to debug the
OP's code sample, closing the ticket does not seem so unreasonable after

The title of the original Debian ticket was, "segfault while doing odd
things with glob refs". 
( So the person
who filed that ticket himself recognized that he was doing something
weird -- stunt programming, in effect, -- which was likely to produce
strange results.  The stunt, of course, is to provide \*STDOUT as one of
the arguments to IO::Tee::new(), then to assign the resulting object
back into STDOUT's slot in the symbol table.

The original Debian poster went on to say, "I have no idea how
wide-ranging or serious this is, nor do I really understand what is
going on here."

Well, I myself don't claim to fully understand what is going on here. 
But I can say that the problem is most likely in IO::Tee, a module which
is not included in the Perl 5 core distribution and which hasn't been
updated in eleven years.  Here is IO::Tee's constructor:

sub new
    my $class = shift;
    my $self = gensym;
    @{*$self} = map {
        ! ref($_) ? IO::File->new($_)
        : ref($_) eq 'ARRAY' ? IO::File->new(@$_)
        : ref($_) eq 'GLOB' ? bless $_, 'IO::Handle'
        : $_ or return undef } @_;
    bless $self, $class;
    tie *$self, $class, $self;
    return $self;

Are there tie/symbol-table experts who can say exactly what is going on
in the 'bless' and 'tie' lines there?  (I tried to step through this
with the debugger and found it difficult to determine what $self and/or
*$self were at any given moment.)

Would this constructor and the subsequent PRINT method be reasonably
able to support the original poster's stunt?

    my $self = shift;
    my $ret = 1;
    foreach my $fh (@$self) { undef $ret unless print $fh @_ }
    return $ret;

If someone has quick answers to this, we can keep this open.  But if it
is not actually a problem with Perl, then I suggest we move it to
IO::Tee's bug queue on CPAN and close it here.

Thank you very much.
Jim Keenan

via perlbug:  queue: perl5 status: new

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