tokuhirom / Test-Pretty

Other
20 stars 17 forks source link

fork() on strawberry perl crashes interpreter in fork.t #26

Open davehorner opened 9 years ago

davehorner commented 9 years ago

to see error in automated test please checkout: http://www.cpantesters.org/cpan/report/9b5aad6d-6fc6-1014-aa23-111fa794d5e7

it is failing on fork.t, on main::(fork.t:8): my $pid = fork(); https://raw.githubusercontent.com/tokuhirom/Test-Pretty/master/t/fork.t

Apparently strawberry perl's implementation of fork() leaves something to be desired.

not that you'll glean much from the data, here is the stack trace for the perl process using proc explorer. ntdll.dll!ZwWaitForMultipleObjects+0xa KERNELBASE.dll!WaitForMultipleObjectsEx+0xed KERNEL32.DLL!WaitForMultipleObjects+0xf KERNEL32.DLL!WerpLaunchAeDebug+0x2373 KERNEL32.DLL!WerpLaunchAeDebug+0x1d97 KERNELBASE.dll!UnhandledExceptionFilter+0x1c7 ntdll.dll!memset+0xbbf7 ntdll.dll!_C_specific_handler+0x87 ntdll.dll!_chkstk+0x9d ntdll.dll!RtlRaiseException+0xedb ntdll.dll!KiUserExceptionDispatcher+0x2e encoding.dll+0x36da perl518.dll!PerlIOBase_dup+0xa3 encoding.dll+0x1493 perl518.dll!PerlIOBase_dup+0x53 encoding.dll+0x1493 perl518.dll!PerlIOBuf_dup+0x70 perl518.dll!Perl_fp_dup+0x45 perl518.dll!PerlIO_list_free+0x327 perl518.dll!perl_clone_using+0xac6 perl518.dll!Perl_get_re_arg+0x3d3f perl518.dll!Perl_setdefout+0x74c4 perl518.dll!Perl_runops_standard+0x16 perl518.dll!perl_run+0x379 perl518.dll!RunPerl+0x168 perl.exe+0x13d7 perl.exe+0x14f8 KERNEL32.DLL!BaseThreadInitThunk+0xd ntdll.dll!RtlUserThreadStart+0x1d

skipping fork() by wrapping a $^O in might resolve this error so that installation with tests work. if ($^O ne 'MSWin32') {

Thanks! --dave

zoffixznet commented 9 years ago

Wrapping a $^O in test won't fix the underlying problem and any modules that use that and fork (or use threads) will segfault, even if the module installs correctly.

The crash can be produced with a simple perl -e "use open qw{:encoding(UTF-8) :std}; fork; " And it doesn't look like it'll be fixed. See: http://www.nntp.perl.org/group/perl.perl5.porters/2012/12/msg196842.html https://rt.perl.org/Public/Bug/Display.html?id=31923 http://markmail.org/message/kgbo6rasx4c7b3zw

dolmen commented 9 years ago

You're lucky: the Encode fix is already available and merged: dankogai/p5-encode#40

dolmen commented 9 years ago

Well, sorry. Despites being related to "use open" on Win32, that is not the exact issue.

zoffixznet commented 9 years ago

The above is just one of the possible examples. The code in this module that causes segfault is open my $fh, "<:encoding(utf-8)", $filename as well as binmode $builder->output(), "encoding($TERM_ENCODING)";