Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

changing STDOUT encoding and fork CRASH

by wolf391 (Initiate)
on Jan 23, 2013 at 02:30 UTC ( #1014823=perlquestion: print w/replies, xml ) Need Help??
wolf391 has asked for the wisdom of the Perl Monks concerning the following question:

could someone shed some light why this program CRASHES the perl interpreter (win7, perl 5.12.4 32bit)
#!/usr/bin/perl use strict; use warnings; use feature qw(say switch); use utf8; binmode( STDOUT, ':encoding(cp1252)'); my $pid = fork; die "Failed to fork: $! \n" unless defined $pid; if ($pid) { say 'bk'; wait; exit 0; } say 'bk'; exit 0;
while THIS works just fine:
#!/usr/bin/perl use strict; use warnings; use feature qw(say switch); use utf8; my $pid = fork; die "Failed to fork: $! \n" unless defined $pid; if ($pid) { binmode( STDOUT, ':encoding(cp1252)'); say 'bk'; wait; exit 0; } binmode( STDOUT, ':encoding(cp1252)'); say 'bk'; exit 0;
really can't wrap my head around why the first example crashes.

Replies are listed 'Best First'.
Re: changing STDOUT encoding and fork CRASH
by bulk88 (Priest) on Jan 23, 2013 at 03:48 UTC
    crash is
    > encoding.dll!PerlIOEncode_getarg(interpreter * my_perl=0x00b430b4 +, _PerlIO * * f=0x00b4382c, clone_params * param=0x0012fa98, int flag +s=1) Line 62 + 0x6 C perl517.dll!PerlIOBase_dup(interpreter * my_perl=0x00b430b4, _Per +lIO * * f=0x00000000, _PerlIO * * o=0x008f43f4, clone_params * param= +0x0012fa98, int flags=1) Line 2303 + 0xc C encoding.dll!PerlIOEncode_dup(interpreter * my_perl=0x00b430b4, _ +PerlIO * * f=0x009ee714, _PerlIO * * o=0x008f43f4, clone_params * par +ams=0x0012fa98, int flags=1) Line 566 + 0x16 C perl517.dll!PerlIO_fdupopen(interpreter * my_perl=0x0012f9cc, _Pe +rlIO * * f=0x00070023, clone_params * param=0x0012fa98, int flags=1) + Line 579 + 0x13 C perl517.dll!Perl_fp_dup(interpreter * my_perl=0x00b430b4, _PerlIO + * * const fp=0x008f43f4, const char type=0, clone_params * const par +am=0x0012fa98) Line 11492 + 0xb C perl517.dll!PerlIO_clone(interpreter * my_perl=0x003c5010, interp +reter * proto=0x00b4382c, clone_params * param=0x0012fa98) Line 693 ++ 0xc C perl517.dll!perl_clone_using(interpreter * proto_perl=0x00345ebc, + unsigned long flags=1, IPerlMem * ipM=0x00000001, IPerlMem * ipMS=0x +009048d8, IPerlMem * ipMP=0x009048f4, IPerlEnv * ipE=0x00904910, IPer +lStdIO * ipStd=0x00904948, IPerlLIO * ipLIO=0x009049e4, IPerlDir * ip +D=0x00904a4c, IPerlSock * ipS=0x00904a78, IPerlProc * ipP=0x00904b28) + Line 13350 C perl517.dll!PerlProcFork(IPerlProc * piPerl=0x003444a8) Line 183 +2 + 0x3e C perl517.dll!Perl_pp_fork(interpreter * my_perl=0x00345ebc) Line +4051 + 0xa C perl517.dll!Perl_runops_standard(interpreter * my_perl=0x00345ebc +) Line 42 + 0x4 C perl517.dll!S_run_body(interpreter * my_perl=0x003c5010, long old +scope=1) Line 2430 + 0xa C perl517.dll!perl_run(interpreter * my_perl=0x00345ebc) Line 2346 + + 0x8 C perl517.dll!RunPerl(int argc=2, char * * argv=0x01342478, char * +* env=0x00342da8) Line 270 + 0x6 C perl.exe!mainCRTStartup() Line 398 + 0xe C kernel32.dll!_BaseProcessStart@4() + 0x23
    SV * PerlIOEncode_getarg(pTHX_ PerlIO * f, CLONE_PARAMS * param, int flags) { PerlIOEncode *e = PerlIOSelf(f, PerlIOEncode); SV *sv = &PL_sv_undef; PERL_UNUSED_ARG(param); PERL_UNUSED_ARG(flags); if (e->enc) { dSP; /* Not 100% sure stack swap is right thing to do during dup ... */ PUSHSTACKi(PERLSI_MAGIC); /* crash here ~bulk88*/
    my_perl->Icurstackinfo is NULL, so doing my_perl->Icurstackinfo->si_next crashes. my_perl->Icurstackinfo->si_next is part of PUSHSTACKi macro. This is a many times reported crash on perlmonks and p5p, google pushstacki and encoding.
Re: changing STDOUT encoding and fork CRASH (bug is bug)
by Anonymous Monk on Jan 23, 2013 at 04:12 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014823]
Approved by mildside
[choroba]: suddenly, a weird noise can be heard, and the conductor stops them
[choroba]: (sorry, was interrupted by a call)
[choroba]: What was that? asks he
[choroba]: and the triangle player says, "That was me. It's written here in the score"
[choroba]: and shows a bar with a note "ohne Triangel"
[choroba]: where "ohne" means "will bend" in Czech
[LanX]: one-day-the- triangle-player-of -an-orchestra-gets -very-sick xD
[choroba]: :)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-03-27 11:57 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (319 votes). Check out past polls.