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

Debugger uses wrong console handle in Windows #16442

Open
p5pRT opened this issue Feb 26, 2018 · 2 comments
Open

Debugger uses wrong console handle in Windows #16442

p5pRT opened this issue Feb 26, 2018 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 26, 2018

Migrated from rt.perl.org#132915 (status was 'new')

Searchable as RT132915$

@p5pRT
Copy link
Author

p5pRT commented Feb 26, 2018

From eric.roode@gmail.com

Created by roode@cpan.org

When the command-line debugger starts up under Windows, the following set
of error messages is issued​:

Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call
didn't work. The COLUMNS and LINES environment variables didn't work. at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 410.
at C​:/Strawberry/perl/vendor/lib/Term/ReadKey.pm line 462.
  Term​::ReadKey​::GetTerminalSize(GLOB(0x2b18bc4)) called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 410
  readline​::get_window_size called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 1114
  readline​::init called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 208
  require Term/ReadLine/readline.pm called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/Perl.pm line 63
  eval {...} called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/Perl.pm line 63
  Term​::ReadLine​::Perl​::new("Term​::ReadLine", "perldb",
GLOB(0x2b9809c), GLOB(0x2b18bc4)) called at C​:/Strawberry/perl/lib/
perl5db.pl line 6871
  DB​::setterm() called at C​:/Strawberry/perl/lib/perl5db.pl line 1852
  DB​::_DB__read_next_cmd(undef) called at C​:/Strawberry/perl/lib/
perl5db.pl line 2789
  DB​::DB called at -e line 1
SetConsoleMode failed, LastError=|5| at
C​:/Strawberry/perl/vendor/lib/Term/ReadKey.pm line 346.
at C​:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 1581.
  readline​::readline(" DB<1> ") called at
C​:/Strawberry/perl/vendor/lib/Term/ReadLine/Perl.pm line 11

Term​::ReadLine​::Perl​::readline(Term​::ReadLine​::Perl=ARRAY(0x2649574), "
DB<1> ") called at C​:/Strawberry/perl/lib/perl5db.pl line 7370
  DB​::readline(" DB<1> ") called at C​:/Strawberry/perl/lib/perl5db.pl
line 1861
  DB​::_DB__read_next_cmd(undef) called at C​:/Strawberry/perl/lib/
perl5db.pl line 2789
  DB​::DB called at -e line 1

The reason for this appears to be that perl5db.pl uses the handle 'con'
under
Windows. But under recent versions of Windows, 'conin' and 'conout' are
more
appropriate to use. And in fact, the Term​::ReadLine that ships with Perl
uses
'conin' and conout'. The offending code appears to be around line 1540 of
perl5db.pl. Below is a patch that fixes the problem.

Thanks,
Eric Roode

---
lib/perl5db.pl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Inline Patch
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index ecc49a814d..33f292f85a 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -1533,10 +1533,13 @@ We then determine what the console should be on
various systems:   undef $console;   \}

-=item * Windows or MSDOS - use C<con>.
+=item * Windows or MSDOS - use C<conin$/conout$> if available, else C<con>.

=cut

+ elsif ( $^O eq 'MSWin32' and -e 'conin$' and -e 'conout$' ) {
+ $console = 'conin$,conout$';
+ }
  elsif ( $^O eq 'dos' or -e "con" or $^O eq 'MSWin32' ) {
  $console = "con";
  }
--
2.14.1.windows.1

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.26.0:

Configured by strawberry-perl at Tue May 30 22:52:30 2017.

Summary of my perl5 (revision 5 version 26 subversion 0) configuration:

  Platform:
    osname=MSWin32
    osvers=6.3
    archname=MSWin32-x86-multi-thread-64int
    uname='Win32 strawberry-perl 5.26.0.1 #1 Tue May 30 22:49:36 2017 i386'
    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='gcc'
    ccflags =' -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='7.1.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=4
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=12
    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='g++'
    ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
    libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\i686-w64-mingw32\lib
C:\STRAWB~1\c\lib\gcc\i686-w64-mingw32\7.1.0
    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=xs.dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'



@INC for perl 5.26.0:
    P:\perl_site\lib\perl5/MSWin32-x86-multi-thread-64int
    P:\perl_site\lib\perl5
    C:/Strawberry/perl/site/lib
    C:/Strawberry/perl/vendor/lib
    C:/Strawberry/perl/lib


Environment for perl 5.26.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=C:\usr\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\Wbem;C:\usr\Python3-6-32\Scripts\;C:\usr\Python3-6-32\;C:\usr\Python2-7-13\Scripts;C:\usr\Python2-7-13;C:\usr\MikTex\miktex\bin;C:\Program
Files\Git\cmd;C:\Users\eroode\AppData\Local\Microsoft\WindowsApps;C:\usr\MikTeX\miktex\bin\x64\
    PERL5LIB=P:\perl_site\lib\perl5
    PERL_BADLANG (unset)
    SHELL (unset)
​

@jgpuckering
Copy link

I tried this fix in 5.38 on Windows 11 and it didn't work for me. Changing con to conin made no difference. Changing it to conout made no difference either. When I directly tested -e con it failed. Same for conin and for conout.

I installed 5.32 to see what the code was like in that release and here's what I found:

=item * Windows or MSDOS - use C<con>.

=cut

    elsif ( $^O eq 'dos' or -e "con" or $^O eq 'MSWin32' ) {
        $console = "con";
    }

Note that the conditions are OR'd whereas in 5.38 they are AND'd.

On a whim I even tried testing -e con: but that failed too.

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

No branches or pull requests

3 participants