develooper Front page | perl.perl5.porters | Postings from January 2005

Re: FAIL TermReadKey-2.30 MSWin32-x86-multi-thread 4.0

Thread Next
From:
Jonathan Stowe
Date:
January 14, 2005 06:49
Subject:
Re: FAIL TermReadKey-2.30 MSWin32-x86-multi-thread 4.0
Message ID:
1105714133.2865.82.camel@localhost
On Fri, 2005-01-14 at 11:31, Jonathan Stowe wrote:
> On Thu, 2005-01-13 at 18:52, rrwo@cpan.org wrote:

> > 
> > GetConsoleMode failed, LastError=|6| at blib\lib/Term/ReadKey.pm line 265.
> > END failed--call queue aborted.
> > NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x9'
> > Stop.
> > 
> 
> Hmm. Most odd, it appears to have gone through all of the tests and then
> failed at some point after the last test.  I think this is probably at
> the:
> 
>    END { ReadMode 0, IN; } 
> 
> which resets the terminal in case of a problem.  The particularly
> strange thing is that I PASS results on the same platform :-(
> 
> I'll try and get a system to test this on, but would it be possible to
> run the test by hand (i.e. perl -Mblib test.pl in the directory where
> the module was unpacked) and send me the results?
> 

Okay I have tracked this down to something strange going on with when
using the 'CONIN$' file - the test code (pared greatly down of course
does:

        use Term::ReadKey;
        
        use Fcntl;
        
        sysopen( IN,  'CONIN$',  O_RDWR );
        
        ReadMode 0, IN;

Which fails with the above error.  ReadMode (of course?) works fine for
STDIN.

On further examination I have distilled it down to:

Test.xs:

        #include "EXTERN.h"
        #include "perl.h"
        #include "XSUB.h"
        
        #include "ppport.h"
        #include <io.h>
        
        MODULE = Test		PACKAGE = Test		
        
        
        void Test(fh)
        	PerlIO *fh
        	CODE:
        {
        	int handle;
        	HANDLE hwnd;
        	handle = PerlIO_fileno(fh);
        
        	if ((hwnd = (HANDLE)_get_osfhandle(handle)) == -1)
        		croak("bad file handle");
        }

Test.t:

        use Test
        use Fcntl;
        
        sysopen( IN,  'CONIN$',  O_RDWR );
        
        Test::Test(IN);
        
Which croaks with the message as above.

In normal usage CONIN$ and CONOUT$ work normally ( I can read, print and
take their fileno()).

So my question is: am I looking at a bug in the MS CRT here ( I am
testing with "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version
13.10.3077" i.e. the one that comes with Visual Studio 2003 ) and if so
are there any workarounds, or is this something strange (bug,
undocumented behaviour?) with PerlIO or indeed (quite likely) something
that I have missed and/or failed to understand. It occurs to me that it
could be something that is happening when the extension is compiled with
a diversion version of the compiler and/or CRT from that which compiled
the Perl but I am not in a position to test this right now.

Any input welcomed, especially testing with various MS compiler and Perl
versions.

Perl version:
Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=def
ine
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -
DNO_STRICT -DHAVE_DES_FCRYPT  -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPL
ICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksi
ze=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-libpath:"C:
\Perl\lib\CORE"  -machine:x86'
    libpth=C:\PROGRA~1\MICROS~3\VC98\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 wsoc
k32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comd
lg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib
wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -
libpath:"C:\Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_
CONTEXT PERL_IMPLICIT_SYS
  Locally applied patches:
        ActivePerl Build 810
        22751 Update to Test.pm 1.25
        21540 Fix backward-compatibility issues in if.pm
  Built under MSWin32
  Compiled at Jun  1 2004 11:52:21
  @INC:
    C:/Perl/lib
    C:/Perl/site/lib
    .

/J\


Thread Next


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