I uncovered some more information on this problem. While the test code I originally posted didn't report anythingon the segfault, this code...

#!/usr/bin/perl -w use strict; use Filter::Handle qw/subs/; Filter \*STDOUT, sub { local $_ = "@_"; s/blue/red/g; $_ }; print "My house is blue.\n"; print "So is my cat, whose nose is blue.\n"; UnFilter \*STDOUT; print "And the plane is also blue.\n";

... gave me a "Deep recursion on subroutine "Filter::Handle::PRINT" at /Library/Perl/5.8.6/Filter/Handle.pm line 42." That gave me some clues, but what I thought was the solution isn't working.

Here is the subroutine with line 42 in it.

sub PRINT { my $self = shift; my $fh = *{ $self->{fh} }; print $fh, $self->{output}->(@_); }

The last line in #42. Immediately I thought perl is getting confused to which print to call and going into an infinite loop until a segfault happens. Thing is prepending CORE:: still ends in the same results.

sub PRINT { my $self = shift; my $fh = *{ $self->{fh} }; CORE::print $fh $self->{output}->(@_); }

I also added a "use subs" for print and printf to no avail.

use subs qw(print printf);

My experiments with Tie::Handle have return similar results so far.

What is happening here to confuse Perl that it goes into an infinite loop? Why is the use of CORE:: getting ignored or changed by this code?

Any ideas would be appreciated.


In reply to Re: Filter::Handle segfault in Perl 5.8+ by tima
in thread Filter::Handle segfault in Perl 5.8+ by tima

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.