Front page | perl.perl5.porters |
Postings from December 2012
[perl #116254] Win32 Perl's signal emulation permanently disables clib signals, then sets them, and excessive win32_signal_context() calls
From:
bulk88
Date:
December 31, 2012 08:53
Subject:
[perl #116254] Win32 Perl's signal emulation permanently disables clib signals, then sets them, and excessive win32_signal_context() calls
Message ID:
rt-3.6.HEAD-17500-1356944010-348.116254-75-0@perl.org
# New Ticket Created by bulk88
# Please include the string: [perl #116254]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116254 >
This is a bug report for perl from bulk88@hotmail.com,
generated with the help of perlbug 1.39 running under perl 5.17.7.
-----------------------------------------------------------------
[Please describe your issue here]
I noticed a redundant call to win32_signal_context from Perl_csighandler
when doing a ctrl-c
________________________________________________________________________________
> perl517.dll!win32_signal_context() Line 4168 C
perl517.dll!Perl_csighandler(int sig=2) Line 1310 + 0x5 C
perl517.dll!do_raise(interpreter * my_perl=0x00346014, int sig=2)
Line 2125 + 0x7 C
perl517.dll!win32_ctrlhandler(unsigned long dwCtrlType=0) Line
4205 + 0xb C
kernel32.dll!_CtrlRoutine@4() + 0x118
kernel32.dll!_BaseThreadStart@8() + 0x37
________________________________________________________________________________
Yet TLS is guarenteed to have an interp by now because of
win32_ctrlhandler also calling win32_signal_context(). Now, perl does
register a sig handler with the CRT
________________________________________________________________________________
> msvcr71.dll!signal(int signum=2, void (int)* sigact=0x28144c40)
Line 227 C
perl517.dll!win32_signal(int sig=2, void (int)* subcode=0x28144c40)
Line 4402 + 0xe C
perl517.dll!PerlProcSignal(IPerlProc * piPerl=0x003445c0, int sig=2,
void (int)* subcode=0x28144c40) Line 1681 + 0xd C
perl517.dll!Perl_rsignal(interpreter * my_perl=0x00346014, int
signo=2, void (int)* handler=0x28144c40) Line 3013 + 0x1e C
perl517.dll!Perl_magic_setsig(interpreter * my_perl=0x00346014, sv *
sv=0x00944884, magic * mg=0x00951184) Line 1536 + 0x14 C
perl517.dll!Perl_mg_set(interpreter * my_perl=0x00346014, sv *
sv=0x00944884) Line 279 + 0x12 C
perl517.dll!Perl_pp_sassign(interpreter * my_perl=0x00346014) Line
223 + 0x3c C
perl517.dll!Perl_runops_standard(interpreter * my_perl=0x00346014)
Line 42 + 0xa C
perl517.dll!S_run_body(interpreter * my_perl=0x00346014, long
oldscope=1) Line 2430 + 0xd C
perl517.dll!perl_run(interpreter * my_perl=0x00346014) Line 2349 C
perl517.dll!RunPerl(int argc=2, char * * argv=0x00342478, char * *
env=0x00345308) Line 270 + 0x9 C
perl.exe!mainCRTStartup() Line 398 + 0xe C
kernel32.dll!_BaseProcessStart@4() + 0x23
____________________________________________________________________________________
but, from my research, a CRT sig handler will never be called, except
through maybe raise(), which win32 perl does not link with (I checked
import table of perl517.dll), the first time signal() is called in the
process, the CRT sets a flag inside itself that it itself called
SetConsoleCtrlHandler, it will never call it again. When Perl removes
the CRT handler, and installs its own, it has disabled CRT signals for
the rest of the process's run. Yet perl continues to register sig
handlers with the CRT even though they never will be called by the OS.
relevant code is
http://perl5.git.perl.org/perl.git/blob/1feab43956f936b2526693e4394a9653fcea6079:/win32/win32.c#l4570
I feel something is redundant here or should be removed. I am not sure
what. If Perl_csighandler can only be called with raise (same thread),
or from win32_ctrlhandler (random OS thread), it needs a normal dTHX,
not a dTHXa(PERL_GET_SIG_CONTEXT);. Maybe Perl should stop registering
Perl_csighandler with the CRT with signal() since that handler will
never be called from the OS, or Perl.
Trying to synthesis a ctrl-c with kill didn't work (
http://perlmonks.org/?node_id=1010891 not sure if this will work on Unix
or not). On some signums, it killed the perl process (NUM05) in
http://perl5.git.perl.org/perl.git/blob/1feab43956f936b2526693e4394a9653fcea6079:/win32/win32.c#l1231
, on others the %SIG was never called (like BREAK) (IDK why yet on BREAK).
Also Perl_sighandler calls win32_signal_context, yet can only be called
from Perl_csighandler or Perl_despatch_signals, both of which already
called win32_signal_context (Perl_csighandler) or always have TLS set up
correctly (Perl_despatch_signals).
Perl's Win32 emulated signals will never be posix compatible, but they
shouldn't do a bad job at what limited capability they have. I'd like
some comments before I try changing any of this code and writing a patch.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.17.7:
Configured by Owner at Sun Dec 16 13:25:34 2012.
Summary of my perl5 (revision 5 version 17 subversion 7 patch blead
2012-12-06.16:42:20 93a641ae382638ffd1980378be4810244d04f4b0
v5.17.6-186-g93a641a) configuration:
Snapshot of: 93a641ae382638ffd1980378be4810244d04f4b0
Platform:
osname=MSWin32, osvers=5.1, 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 -GL -G7
-DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-D_USE_32BIT_TIME_T',
optimize='-MD -Zi -DNDEBUG -O1 -GL -G7',
cppflags='-DWIN32'
ccversion='13.10.6030', 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
-ltcg -libpath:"c:\perl517\lib\CORE" -machine:x86'
libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\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=perl517.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:"c:\perl517\lib\CORE" -machine:x86'
Locally applied patches:
---
@INC for perl 5.17.7:
C:/perl517/site/lib
C:/perl517/lib
.
---
Environment for perl 5.17.7:
HOME (unset)
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=C:\perl517\bin;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
PERL_BADLANG (unset)
SHELL (unset)
-
[perl #116254] Win32 Perl's signal emulation permanently disables clib signals, then sets them, and excessive win32_signal_context() calls
by bulk88