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

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

Thread Next
From:
James E Keenan via RT
Date:
September 1, 2012 10:03
Subject:
[perl #70001] interpreter crash with IO::Tee
Message ID:
rt-3.6.HEAD-11172-1346518990-387.70001-15-0@perl.org
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
all.

The title of the original Debian ticket was, "segfault while doing odd
things with glob refs". 
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=158539) 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?

#####
sub PRINT
{
    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
https://rt.perl.org:443/rt3/Ticket/Display.html?id=70001

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