Skip Menu |
 

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 125689
Status: new
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: tlhackque [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Tk::IO broken under Windows, partial diagnosis, need help
Date: Tue, 26 Jun 2018 13:41:28 -0400
To: bug-Tk [...] rt.cpan.org
From: tlhackque <tlhackque [...] yahoo.com>
Download (untitled) / with headers
text/plain 5.6k
Tk::IO does not work under windows. The first issue is that the exec code starts with:   my $pid = open($fh,'-|'); As documented here:  https://perldoc.perl.org/perlfork.html this isn't supported under windows. I applied the obvious work-around (actually, several variants):  my $wr;  pipe( $fh, $wr ) or die( "pipe: $!\n" ); my $pid = fork; die( "fork $!" ) unless( defined $pid );  if ($pid)   {    close( $wr ); ...  else   {    # make STDERR same as STDOUT here    setpgrp;    open( STDOUT, '>&=' . fileno( $wr ) ) or die( "Child open $!\n" );    exec(@_) || die 'Cannot exec ',join(' ',@_),":$!"; However,  this wins:   panic: restartop   'Free to wrong pool 8a59d70 not dc8090 at C:/Perl64/site/lib/Tk.pm line 251. apparently from the child process. This seems odd, since the exec should not run down Perl. In fact, if the ONLY statement in the child is the exec, it still dies. If I put a sleep before the exec, the crash happens after the timeout. This indicates that it's not the setpgrp or the open of STDOUT in the child that triggers/detects the corruption, but something impacted by the exec. I'm not enough of an XS person to debug further, but I would like this to work. Also, I tried exec'ing several programs; from echo to another Perl program; nothing changes. The real target is a perl script - but it knows nothing about tk. This work done under Windows 10, Activestate Perl 5.26.1 (full -V follows). Tk version 0804.034  Tk::IO 4.006. Thanks in advance. Here is my entire patched version (I simply overload the Tk::IO::exec function: package Tl::IO; our @ISA = ( qw/Tk::IO/ ); sub exec {  my $fh  = shift; # my $pid = open($fh,'-|');  my $wr;  pipe( $fh, $wr ) or die( "pipe: $!\n" ); my $pid = fork; die( "fork $!" ) unless( defined $pid );  if ($pid)   {    close( $wr );    ${*$fh} = '' unless (defined ${*$fh});    ${*$fh}{'-exec'} = [@_];    ${*$fh}{'-pid'}  = $pid;    if (exists ${*$fh}{-linecommand})     {      my $w = ${*$fh}{-widget};      $w = 'Tk' unless (defined $w);      $w->fileevent($fh,'readable',[$fh,'readable']);      ${*$fh}{_readable} = $w;     }    else     {      require Tk::Pretty;      croak Tk::Pretty::Pretty(\%{*$fh});     }    return $pid;   }  else   {    # make STDERR same as STDOUT here    setpgrp;    open( STDOUT, '>&=' . fileno( $wr ) ) or die( "Child open $!\n" );  sleep( 20 );     exec(@_) || die 'Cannot exec ',join(' ',@_),":$!";   } } Summary of my perl5 (revision 5 version 26 subversion 1) configuration:   Platform:     osname=MSWin32     osvers=6.1     archname=MSWin32-x64-multi-thread     uname=''     config_args='undef'     hint=recommended     useposix=true     d_sigaction=undef     useithreads=define     usemultiplicity=define     use64bitint=define     use64bitall=undef     uselongdouble=undef     usemymalloc=n     default_inc_excludes_dot=define     bincompat5005=undef   Compiler:     cc='C:\Perl64\site\bin\gcc.exe'     ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields'     optimize='-s -O2'     cppflags='-DWIN32'     ccversion=''     gccversion='4.6.3'     gccosandvers=''     intsize=4     longsize=4     ptrsize=8     doublesize=8     byteorder=12345678     doublekind=3     d_longlong=define     longlongsize=8     d_longdbl=define     longdblsize=16     longdblkind=3     ivtype='long long'     ivsize=8     nvtype='double'     nvsize=8     Off_t='long long'     lseeksize=8     alignbytes=8     prototype=define   Linker and Libraries:     ld='C:\Perl64\site\bin\g++.exe'     ldflags ='-s -static-libgcc -static-libstdc++ -L"C:\Perl64\lib\CORE" -L"C:\MinGW\x86_64-w64-mingw32\lib"'     libpth=C:\MinGW\x86_64-w64-mingw32\lib     libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32     perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32     libc=     so=dll     useshrplib=true     libperl=libperl526.a     gnulibc_version=''   Dynamic Linking:     dlsrc=dl_win32.xs     dlext=dll     d_dlsymun=undef     ccdlflags=' '     cccdlflags=' '     lddlflags='-mdll -s -static-libgcc -static-libstdc++ -L"C:\Perl64\lib\CORE" -L"C:\MinGW\x86_64-w64-mingw32\lib"' Characteristics of this binary (from libperl):   Compile-time options:     HAS_TIMES     HAVE_INTERP_INTERN     MULTIPLICITY     PERLIO_LAYERS     PERL_COPY_ON_WRITE     PERL_DONT_CREATE_GVSV     PERL_IMPLICIT_CONTEXT     PERL_IMPLICIT_SYS     PERL_MALLOC_WRAP     PERL_OP_PARENT     PERL_PRESERVE_IVUV     USE_64_BIT_INT     USE_ITHREADS     USE_LARGE_FILES     USE_LOCALE     USE_LOCALE_COLLATE     USE_LOCALE_CTYPE     USE_LOCALE_NUMERIC     USE_LOCALE_TIME     USE_PERLIO     USE_PERL_ATOF     USE_SITECUSTOMIZE   Locally applied patches:     ActivePerl Build 2601 [404865]   Built under MSWin32   Compiled at Dec 11 2017 12:23:25   @INC:     C:/Perl64/site/lib     C:/Perl64/lib


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.