Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

The following program produces a segmentation fault with perl 5.10.1, 5.20.3, and 5.22.2:

#!/usr/bin/perl use strict; use warnings; use threads; binmode STDOUT, ':encoding(utf-8)'; for my $i (1..4) { threads->create(sub {})->join(); }

Is this a known bug?

Replies are listed 'Best First'.
Re: Segmentation fault with threads and binmode utf-8
by BrowserUk (Patriarch) on May 05, 2016 at 10:34 UTC

    As a work around, using the open pragma doesn't cause the crash:

    #! perl -slw use strict; use threads; use open OUT => ':utf8'; #use open ':encoding(utf8)'; print async{ "\x120\x121\x122\x123\n" }->join;

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Segmentation fault with threads and binmode utf-8
by dave_the_m (Monsignor) on May 05, 2016 at 09:54 UTC
    This was fixed in perl 5.23.4 by commit 0ee3fa26f66

    Dave.

        How dependent is "PerlIO::encoding" on perl version? Can it be dual-lived module?
        I don't know.

        Dave.

        How dependent is "PerlIO::encoding" on perl version? Can it be dual-lived module?

        As is, it cannot, you'll encounter encoding.o:encoding.c:(.text+0x91d): undefined reference to `Perl_PerlIO_save_errno' , Perl_PerlIO_save_errno is only available in the newest perls

Re: Segmentation fault with threads and binmode utf-8
by Anonymous Monk on May 05, 2016 at 08:41 UTC