Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 fork and encoding simultaneous usage error #11171

Closed
p5pRT opened this issue Mar 3, 2011 · 10 comments
Closed

Win32 fork and encoding simultaneous usage error #11171

p5pRT opened this issue Mar 3, 2011 · 10 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Mar 3, 2011

Migrated from rt.perl.org#85366 (status was 'resolved')

Searchable as RT85366$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Mar 3, 2011

From whylivealife@gmail.com

This is a bug report for perl from whylivealife@​gmail.com,
generated with the help of perlbug 1.39 running under perl v5.8.9.


Perl crashes if script simultaneously uses encoding pragma and fork.

use strict;
use warnings;
use encoding 'utf-8';
my $pid = fork;
unless($pid)
{
  while(1)
  {
  print 1;
  sleep 1;
  }
}

I think it crashes on macro
PUSHSTACKi(PERLSI_MAGIC);

from method
SV *
PerlIOEncode_getarg(pTHX_ PerlIO * f, CLONE_PARAMS * param, int flags)

at
encoding.xs

However, it doesn't crash if i close STDIN and STDOUT before calling fork.



Flags​:
  category=library
  severity=medium
  module=encoding


Site configuration information for perl v5.8.9​:

Configured by sshd_server at Wed Jan 27 16​:09​:40 2010.

Summary of my perl5 (revision 5 version 8 subversion 9) configuration​:
  Platform​:
  osname=MSWin32, osvers=5.2, archname=MSWin32-x64-multi-thread
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=define use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -Ox -GL -Wp64
-fp​:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DWIN64
-DCONSERVATIVE -DNO_HASH_SEED -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX',
  optimize='-MD -Zi -DNDEBUG -Ox -GL -Wp64 -fp​:precise',
  cppflags='-DWIN32'
  ccversion='14.00.40310.41', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
  ivtype='__int64', ivsize=8, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='link', ldflags ='-nologo -nodefaultlib -debug -opt​:ref,icf -ltcg
-libpath​:"D​:\Perl64\lib\CORE" -machine​:AMD64'
  libpth=\lib
  libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
bufferoverflowU.lib msvcrt.lib
  perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
bufferoverflowU.lib msvcrt.lib
  libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl58.lib
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt​:ref,icf -ltcg -libpath​:"D​:\Perl64\lib\CORE" -machine​:AMD64'

Locally applied patches​:
  ACTIVEPERL_LOCAL_PATCHES_ENTRY
  f7bbab select() generates 'Invalid parameter' messages on Windows Vista.
  36f064 do/require don't treat '.\foo' or '..\foo' as absolute paths on
Windows
  287a96 Fix -p function and Fcntl​::S_IFIFO constant under Microsoft VC
compiler
  Iin_load_module moved for compatibility with build 806
  Avoid signal flag SA_RESTART for older versions of HP-UX
  Less verbose ExtUtils​::Install and Pod​::Find
  Rearrange @​INC so that 'site' is searched before 'perl'
  Partly reverted #dafda6 to preserve binary compatibility
  5e162c Problem killing a pseudo-forked child on Win32
  3e5d88 ANSIfy the PATH environment variable on Windows
  c71e9b,29e136 win32_async_check() can loop indefinitely
  aeecf6 Fix alarm() for Windows 2003


@​INC for perl v5.8.9​:
  D​:/Perl64/site/lib
  D​:/Perl64/lib
  .


Environment for perl v5.8.9​:
  CYGWIN=tty
  HOME (unset)
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=C​:\Program Files\Common Files\Microsoft Shared\Windows
Live;D​:\Program Files (x86)\ImageMagick-6.6.6-Q8;C​:\Program Files
(x86)\NVIDIA
Corporation\PhysX\Common;D​:\Perl64\site\bin;D​:\Perl64\bin;C​:\Program Files
(x86)\ATI Stream\bin\x86_64;C​:\Program Files (x86)\ATI
Stream\bin\x86;C​:\Windows\system32;C​:\Windows;C​:\Windows\System32\Wbem;C​:\Windows\System32\WindowsPowerShell\v1.0\;C​:\Program
Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;C​:\Program Files
(x86)\Toshiba\Bluetooth Toshiba Stack\sys\;C​:\Program Files
(x86)\Toshiba\Bluetooth Toshiba Stack\sys\x64\;C​:\Program Files (x86)\ATI
Technologies\ATI.ACE\Core-Static;D​:\masm32\bin;D​:\Program
Files\MATLAB\R2010b\runtime\win64;D​:\Program
Files\MATLAB\R2010b\bin;D​:\Tools;D​:\Program Files
(x86)\Mono-2.6.7\bin;D​:\Program Files\TortoiseSVN\bin;D​:\Program
Files\Java\jre6\bin;C​:\Program Files (x86)\Common Files\Autodesk
Shared\;C​:\Program Files (x86)\QuickTime\QTSystem\;C​:\Program Files\Common
Files\Microsoft Shared\Windows Live;D​:\Program Files (x86)\CMake
2.8\bin;D​:\Program Files (x86)\Nmap;D​:\Program Files (x86)\OpenVPN\bin
  PERL_BADLANG (unset)
  SHELL (unset)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2011

From @kmx

just adding cross reference to related RT

http​://rt.perl.org/rt3/Ticket/Display.html?id=89142

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Apr 26, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 15, 2016

From @cpansprout

I am removing the link to the encoding.pm ticket, since it is not related to encoding.pm per se. The same bug can be triggered this way​:

binmode STDOUT, "​:encoding(utf8)";
use threads;
async
{
  for (1..10)
  {
  print "1\n";
  sleep 1;
  }
}

I think this may have been fixed already, but I don’t have a threaded blead handy right now.

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 15, 2016

From @dcollinsn

On Fri Jul 15 08​:55​:56 2016, sprout wrote​:

I think this may have been fixed already, but I don’t have a threaded
blead handy right now.

I do, it is fixed. I'll bisect and report back.

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 15, 2016

From perl@profvince.com

Le 15/07/2016 à 13​:02, Dan Collins via RT a écrit :

On Fri Jul 15 08​:55​:56 2016, sprout wrote​:

I think this may have been fixed already, but I don’t have a threaded
blead handy right now.

I do, it is fixed. I'll bisect and report back.

This is a duplicate of #31923, which has been fixed in 5.24.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 15, 2016

From @dcollinsn

On Fri Jul 15 09​:02​:15 2016, dcollinsn@​gmail.com wrote​:

On Fri Jul 15 08​:55​:56 2016, sprout wrote​:

I think this may have been fixed already, but I don’t have a threaded
blead handy right now.

I do, it is fixed. I'll bisect and report back.

This was fixed by the same commit as 41121.

commit 0ee3fa2
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

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 15, 2016

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT p5pRT closed this May 30, 2017
@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant