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

Absence of POSIX::_SC_OPEN_MAX on Windows makes perl debugger restart fail [includes workaround] #11235

Closed
p5pRT opened this issue Apr 4, 2011 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 4, 2011

Migrated from rt.perl.org#87740 (status was 'open')

Searchable as RT87740$

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2011

From louis.strous@gmail.com

This is a bug report for perl from louis.strous@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.12.3.

SUMMARY​: Absence of POSIX​::_SC_OPEN_MAX on Windows makes perl debugger
restart fail
[includes workaround]

Reported by​: Louis Strous, louis.strous@​gmail.com, 2011-04-04
(Also found reported at
http​://community.activestate.com/forum-topic/restarting-native-perl-debugger-perl-5-008008
on 2007-11-25)

PERL VERSION​: 5.12.3, 5.10.1, 5.008008

REPRODUCTION SCENARIO​: Start debugger for some perl script, enter "R"
command to restart.
Get no restart, but error message about POSIX macro _SC_OPEN_MAX and
termination of
debugged program. Entering "R" again yields a similar error message
and terminates the debugger. See session log below.

SESSION LOG​:
File A.pl contains the single line 'print "in A\n";'.

C​:\Users\swtester\Documents>perl -d A.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main​::(A.pl​:1)​: print "in A\n";

  DB<1> R
Warning​: some settings and command-line options may be lost!
Your vendor has not defined POSIX macro _SC_OPEN_MAX, used at
C​:/Perl/lib/perl5db.pl line 3334
at C​:/Perl/lib/POSIX.pm line 50
  POSIX​::AUTOLOAD() called at C​:/Perl/lib/perl5db.pl line 3334
  DB​::DB called at A.pl line 1
Debugged program terminated. Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.

  DB<1> R
Warning​: some settings and command-line options may be lost!
Your vendor has not defined POSIX macro _SC_OPEN_MAX, used at
C​:/Perl/lib/perl5db.pl line 3334
END failed--call queue aborted at A.pl line 62.
at A.pl line 62

C​:\Users\swtester\Documents>
<<

DIAGNOSIS​:
Lines 3332-3335 of perl5db.pl read​:

  my $max_fd = 1024; # default if POSIX can't be loaded
  if (eval { require POSIX }) {
  $max_fd = POSIX​::sysconf(POSIX​::_SC_OPEN_MAX());
  }
<<

POSIX Is available but POSIX​::_SC_OPEN_MAX is not defined on Windows.
This yields an
exception, which means that the "restart" code following these lines
is not executed,
so no proper restart is done. If POSIX weren't available at all, then
a default value
of 1024 would be used for $max_fd.

VERIFICATION OF DIAGNOSIS​:
Run the following test program​:

use strict;
use warnings;

my $max_fd = 1024;
if (eval { require POSIX }) {
  print "POSIX available\n";
  $max_fd = POSIX​::sysconf(POSIX​::_SC_OPEN_MAX());
  print "max_fd = $max_fd\n";
} else {
  print "POSIX not available\n";
}
print "Done.\n";
<<

Get output​:

C​:\Users\swtester\Documents>perl A.pl
POSIX available
Your vendor has not defined POSIX macro _SC_OPEN_MAX, used at A.pl line 7

C​:\Users\swtester\Documents>
<<

If no exception occurred, then at least a "Done." message should have
been printed.

WORKAROUND​:
A proper solution would be to implement POSIX​::_SC_OPEN_MAX() for
Windows. I don't
know how to do that. A workaround is to not cause an exception if
_SC_OPEN_MAX is
not defined, but instead use the default value that has already been
defined in case
POSIX cannot be loaded at all. Do this by wrapping line 3334 of
perl5db.pl in an
eval { }​:

  my $max_fd = 1024; # default if POSIX can't be loaded
  if (eval { require POSIX }) {
  eval { $max_fd =
POSIX​::sysconf(POSIX​::_SC_OPEN_MAX()) };
  }
<<

Then on Windows the default value of 1024 gets used for $max_fd, just
like if POSIX
were not available at all. This seems to work OK for me on Windows 7.
I can now
restart the debugger, and breakpoints are retained.


Flags​:
  category=core
  severity=high


Site configuration information for perl 5.12.3​:

Configured by gecko at Wed Feb 9 14​:35​:46 2011.

Summary of my perl5 (revision 5 version 12 subversion 3) configuration​:

  Platform​:
  osname=MSWin32, osvers=5.2, archname=MSWin32-x86-multi-thread
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  useithreads=define, usemultiplicity=define
  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 -DUSE_SITECUSTOMIZE
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-D_USE_32BIT_TIME_T -DPERL_MSVCRT_READFIX',
  optimize='-MD -Zi -DNDEBUG -O1',
  cppflags='-DWIN32'
  ccversion='12.00.8168', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
  ivtype='long', ivsize=4, 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
-libpath​:"C​:\Perl\lib\CORE" -machine​:x86'
  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 comctl32.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 comctl32.lib msvcrt.lib
  libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl512.lib
  gnulibc_version=''
  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'

Locally applied patches​:
  ACTIVEPERL_LOCAL_PATCHES_ENTRY
  c6fbf28 [perl #71806] perldb does not setup %dbline with the
shebang option -d
  1fd8fa4 Add Wolfram Humann to AUTHORS
  f120055 make string-append on win32 100 times faster
  a2a8d15 Define _USE_32BIT_TIME_T for VC6 and VC7
  007cfe1 Don't pretend to support really old VC++ compilers
  6d8f7c9 Get rid of obsolete PerlCRT.dll support
  d956618 Make Term​::ReadLine​::findConsole fall back to STDIN if
/dev/tty can't be opened
  321e50c Escape patch strings before embedding them in patchlevel.h


@​INC for perl 5.12.3​:
  C​:/Perl/site/lib
  C​:/Perl/lib
  .


Environment for perl 5.12.3​:
  HOME (unset)
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=C​:\Perl\site\bin;C​:\Perl\bin;C​:\Windows\system32;C​:\Windows;C​:\Windows\System32\Wbem;C​:\Windows\System32\WindowsPowerShell\v1.0\
  PERL_BADLANG (unset)
  SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented May 19, 2011

From @cpansprout

On Mon Apr 04 01​:43​:59 2011, louis.strous@​gmail.com wrote​:

                my $max\_fd = 1024; \# default if POSIX can't be

loaded
if (eval { require POSIX }) {
eval { $max_fd =
POSIX​::sysconf(POSIX​::_SC_OPEN_MAX()) };
}
<<

Thank you. Applied as 5332cc6.

Does anyone know how to write a test for this?

@p5pRT
Copy link
Author

p5pRT commented May 19, 2011

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

@toddr
Copy link
Member

toddr commented Feb 13, 2020

I think we can call that a no :)

@toddr toddr closed this as completed Feb 13, 2020
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

2 participants