develooper Front page | perl.perl5.porters | Postings from August 2016

[perl #89142] On Win32 setting any encoding on STD(IN|OUT|ERR) withbinmode causes subsequent fork calls to crash perl

From:
Dan Collins via RT
Date:
August 17, 2016 00:32
Subject:
[perl #89142] On Win32 setting any encoding on STD(IN|OUT|ERR) withbinmode causes subsequent fork calls to crash perl
Message ID:
rt-4.0.24-4027-1471393942-181.89142-15-0@perl.org
This is fixed in 5.24.0:

dcollins@nightshade64:~$ perl5.22.0-thread-multi -wle "use threads; binmode STDOUT, ':encoding(greek)'; async { print 1} print 1"
1
Segmentation fault
dcollins@nightshade64:~$ perl5.24.0-thread-multi -wle "use threads; binmode STDOUT, ':encoding(greek)'; async { print 1} print 1"
1
Perl exited with active threads:
        1 running and unjoined
        0 finished and unjoined
        0 running and detached

Bisect says it was fixed by:

0ee3fa26f660ac426e3e082f77d806c9d1471f93 is the first new commit
commit 0ee3fa26f660ac426e3e082f77d806c9d1471f93
Author: Vincent Pit <perl@profvince.com>
Date:   Fri Aug 28 14:17:00 2015 -0300

    Properly duplicate PerlIO::encoding objects

    PerlIO::encoding objects are usually initialized by calling Perl methods,
    essentially from the pushed() and getarg() callbacks. During cloning, the
    PerlIO API will by default call these methods to initialize the duplicate
    struct when the PerlIOBase parent struct is itself duplicated. This does
    not behave so well because the perl interpreter is not ready to call
    methods at this point, for the stacks are not set up yet.

    The proper way to duplicate the PerlIO::encoding object is to call sv_dup()
    on its members from the dup() PerlIO callback. So the only catch is to make
    the getarg() and pushed() calls implied by the duplication of the underlying
    PerlIOBase object aware that they are called during cloning, and make them
    wait that the control flow returns to the dup() callback. Fortunately,
    getarg() knows since its param argument is then non-null, and its return
    value is passed immediately to pushed(), so it is enough to tag this
    returned value with a custom magic so that pushed() can see it is being
    called during cloning.

    This fixes [RT #31923].

:100644 100644 f79df008098f4df1f97f7f104171b89c31049a90 34c2e2436a2a14e776725ca5c40a74c8f0a4bdb7 M      MANIFEST
:040000 040000 ce197fb6173fb13198e80fa4a743778f88a797d4 16376953f016ecdaf6dbe144a432d6d683e00229 M      ext


I'm marking this resolved.


-- 
Respectfully,
Dan Collins

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=89142



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About