Navigation Menu

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

[PATCH] move Win32's $^X code to where all other OSes' $^X code lives #15066

Closed
p5pRT opened this issue Nov 28, 2015 · 11 comments
Closed

[PATCH] move Win32's $^X code to where all other OSes' $^X code lives #15066

p5pRT opened this issue Nov 28, 2015 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 28, 2015

Migrated from rt.perl.org#126753 (status was 'resolved')

Searchable as RT126753$

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

Created by @bulk88

2 patches attached.

This patch came from research on EUMM commit "MM_Unix​::find_perl() dont
repeatedly stat the same path in a loop"
Perl-Toolchain-Gang/ExtUtils-MakeMaker#245 .

I attached syscall logs before and after of how EUMM searches for the
absolute path to perl. Since EUMM commit "MM_Unix​::find_perl() dont
repeatedly stat the same path in a loop" isn't in blead, you can see the
same file not found path "C​:\p523\src\ext\miniperl.exe" stat-ed 16 times
in a row. After the EUMM patch not in blead the bad file path would have
been stat-ed just once. With this core patch making $^X absolute for
Win32 miniperl, the first stat will always succeed.

Perl Info

Flags:
       category=core
       severity=low

Site configuration information for perl 5.23.5:

Configured by Owner at Sun Oct 25 19:14:27 2015.

Summary of my perl5 (revision 5 version 23 subversion 5) configuration:
     Derived from: 644207b7a8ff7a2b1661c05a7f9ac2df9a5dad91
     Platform:
       osname=MSWin32, osvers=6.1, archname=MSWin32-x86-multi-thread
       uname=''
       config_args='undef'
       hint=recommended, useposix=true, d_sigaction=undef
       useithreads=define, usemultiplicity=define
       use64bitint=undef, use64bitall=undef, uselongdouble=undef
       usemymalloc=n, bincompat5005=undef
     Compiler:
       cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL 
-DWIN32 -D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS 
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS',
       optimize='-O1 -MD -Zi -DNDEBUG -GL',
       cppflags='-DWIN32'
       ccversion='18.00.31101', gccversion='', gccosandvers=''
       intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, 
doublekind=3
       d_longlong=undef, longlongsize=8, d_longdbl=define, 
longdblsize=8, longdblkind=0
       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:\p523\lib\CORE"         -machine:x86 
"/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'
       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=perl523.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:\p523\lib\CORE"  -machine:x86 
"/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'

Locally applied patches:
       uncommitted-changes


@INC for perl 5.23.5:
       C:/p523/site/lib
       C:/p523/lib
       .


Environment for perl 5.23.5:
       HOME (unset)
       LANG (unset)
       LANGUAGE (unset)
       LD_LIBRARY_PATH (unset)
       LOGDIR (unset)
       PATH=C:\p523\site\bin;C:\p523\bin;C:\Program Files\ActiveState 
Komodo Edit 
9\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files\TortoiseGit\bin;C:\Program Files\Microsoft Windows Performance 
Toolkit\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program 
Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program 
Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft 
SDKs\TypeScript\1.0\;C:\Program Files\TortoiseHg\;
       PERL_BADLANG (unset)
       SHELL (unset)




@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

"Time of Day","Process Name","PID","Operation","Result","Path","Detail"
"12​:09​:44.9246589 AM","miniperl.exe","2476","Process Create","SUCCESS","C​:\Windows\system32\cmd.exe","PID​: 2500, Command line​: cmd.exe /x/d/c cd"
"12​:09​:44.9246879 AM","miniperl.exe","2476","QuerySecurityFile","SUCCESS","C​:\Windows\System32\cmd.exe","Information​: Owner, Group, DACL, SACL, Label"
"12​:09​:44.9247006 AM","miniperl.exe","2476","QueryBasicInformationFile","SUCCESS","C​:\Windows\System32\cmd.exe","CreationTime​: 11/20/2010 4​:29​:12 PM, LastAccessTime​: 11/20/2010 4​:29​:12 PM, LastWriteTime​: 11/20/2010 4​:29​:12 PM, ChangeTime​: 4/5/2015 5​:58​:34 AM, FileAttributes​: A"
"12​:09​:44.9258757 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\Windows\System32\cmd.exe",""
"12​:09​:44.9524917 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9525216 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9525413 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9527712 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9531407 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9531658 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9531825 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9535270 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9538263 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9538557 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9538733 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9541066 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9543703 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9543940 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9544103 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9546067 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9548682 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9548919 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9549077 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9551252 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9553907 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9554157 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9554320 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9556324 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9559070 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9559312 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9559479 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9561513 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9564194 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9564436 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9564598 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9566593 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9569265 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9569511 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9569678 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9571840 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9574499 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9574736 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9574899 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9576880 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9579543 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9579785 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9579952 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9582070 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9584768 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9585015 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9585177 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9587528 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9590231 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9590477 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9590639 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9592634 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9595328 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9595570 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9595732 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9597732 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9600500 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9600742 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9600909 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9602913 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9605585 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9605826 AM","miniperl.exe","2476","QueryDirectory","NO SUCH FILE","C​:\p523\src\ext\miniperl.exe","Filter​: miniperl.exe"
"12​:09​:44.9605989 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext",""
"12​:09​:44.9607975 AM","miniperl.exe","2476","CreateFile","NAME NOT FOUND","C​:\p523\src\ext\miniperl.exe","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a"
"12​:09​:44.9610739 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9610985 AM","miniperl.exe","2476","QueryDirectory","SUCCESS","C​:\p523\src\miniperl.exe","Filter​: miniperl.exe, 1​: miniperl.exe"
"12​:09​:44.9611337 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src",""
"12​:09​:44.9615266 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\ext\B","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9615490 AM","miniperl.exe","2476","QueryBasicInformationFile","SUCCESS","C​:\p523\src\ext\B","CreationTime​: 4/6/2015 3​:28​:26 AM, LastAccessTime​: 11/28/2015 12​:05​:42 AM, LastWriteTime​: 11/28/2015 12​:05​:42 AM, ChangeTime​: 11/28/2015 12​:05​:42 AM, FileAttributes​: D"
"12​:09​:44.9615569 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\ext\B",""
"12​:09​:44.9617001 AM","miniperl.exe","2476","CreateFile","SUCCESS","C​:\p523\src\miniperl.exe","Desired Access​: Read Data/List Directory, Execute/Traverse, Read Attributes, Synchronize, Disposition​: Open, Options​: Synchronous IO Non-Alert, Non-Directory File, Attributes​: n/a, ShareMode​: Read, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"12​:09​:44.9617313 AM","miniperl.exe","2476","CreateFileMapping","FILE LOCKED WITH ONLY READERS","C​:\p523\src\miniperl.exe","SyncType​: SyncTypeCreateSection, PageProtection​: PAGE_EXECUTE"
"12​:09​:44.9618900 AM","miniperl.exe","2476","CreateFileMapping","SUCCESS","C​:\p523\src\miniperl.exe","SyncType​: SyncTypeOther"
"12​:09​:44.9619691 AM","miniperl.exe","2476","QuerySecurityFile","SUCCESS","C​:\p523\src\miniperl.exe","Information​: Label"
"12​:09​:44.9621062 AM","miniperl.exe","2476","QueryNameInformationFile","SUCCESS","C​:\p523\src\miniperl.exe","Name​: \p523\src\miniperl.exe"
"12​:09​:44.9621734 AM","miniperl.exe","2476","Process Create","SUCCESS","C​:\p523\src\miniperl.exe","PID​: 3772, Command line​: ""..\..\miniperl.exe"" -le ""require 5; print qq{VER_OK}"""
"12​:09​:44.9621756 AM","miniperl.exe","3772","Process Start","SUCCESS","","Parent PID​: 2476, Command line​: ""..\..\miniperl.exe"" -le ""require 5; print qq{VER_OK}"", Current directory​: C​:\p523\src\ext\B\, Environment​:
; =​::=​::\
; =C​:=C​:\p523\src\ext\B
; =ExitCode=00000000
; ALLUSERSPROFILE=C​:\ProgramData
; APPDATA=C​:\Users\Owner\AppData\Roaming
; CommonProgramFiles=C​:\Program Files\Common Files
; COMPUTERNAME=DELLWIN7
; ComSpec=C​:\Windows\system32\cmd.exe
; DevEnvDir=C​:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\
; EMXSHELL=sh
; ExtensionSdkDir=C​:\Program Files\Microsoft SDKs\Windows\v8.1\ExtensionSDKs
; FP_NO_HOST_CHECK=NO
; Framework40Version=v4.0
; FrameworkDir=C​:\Windows\Microsoft.NET\Framework\
; FrameworkDIR32=C​:\Windows\Microsoft.NET\Framework\
; FrameworkVersion=v4.0.30319
; FrameworkVersion32=v4.0.30319
; FSHARPINSTALLDIR=C​:\Program Files\Microsoft SDKs\F#\3.1\Framework\v4.0\
; FTP_PASSIVE=1
; HOMEDRIVE=C​:
; HOMEPATH=\Users\Owner
; INCLUDE=C​:\Program Files\Microsoft Visual Studio 12.0\VC\INCLUDE;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C​:\Program Files\Windows Kits\8.1\include\shared;C​:\Program Files\Windows Kits\8.1\include\um;C​:\Program Files\Windows Kits\8.1\include\winrt;
; LIB=C​:\Program Files\Microsoft Visual Studio 12.0\VC\LIB;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\LIB;C​:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86;
; LIBPATH=C​:\Windows\Microsoft.NET\Framework\v4.0.30319;C​:\Program Files\Microsoft Visual Studio 12.0\VC\LIB;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\LIB;C​:\Program Files\Windows Kits\8.1\References\CommonConfiguration\Neutral;C​:\Program Files\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\Microsoft.VCLibs\12.0\References\CommonConfiguration\neutral;
; LOCALAPPDATA=C​:\Users\Owner\AppData\Local
; LOGONSERVER=\\DELLWIN7
; NUMBER_OF_PROCESSORS=2
; OS=Windows_NT
; Path=C​:\p523\src\win32\..;C​:\p523\src\win32\..\win32\bin;C​:\p520\site\bin;C​:\p520\bin;C​:\sp520\c\bin;C​:\p523\site\bin;C​:\p523\bin;C​:\Windows\system32;C​:\Program Files\Microsoft Visual Studio 12.0\VC\BIN;C​:\Program Files\Windows Kits\8.1\bin\x86;C​:\Windows;C​:\Program Files\ActiveState Komodo Edit 9;C​:\Program Files\Git\bin;;;
; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
; PERL_CORE=1
; PERL_MM_USE_DEFAULT=1
; PROCESSOR_ARCHITECTURE=x86
; PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 6, GenuineIntel
; PROCESSOR_LEVEL=6
; PROCESSOR_REVISION=0f06
; ProgramData=C​:\ProgramData
; ProgramFiles=C​:\Program Files
; PROMPT=$P$G
; PSModulePath=C​:\Windows\system32\WindowsPowerShell\v1.0\Modules\
; PUBLIC=C​:\Users\Public
; PWD=C​:/p523/src/ext/B
; SESSIONNAME=Console
; SystemDrive=C​:
; SystemRoot=C​:\Windows
; TEMP=C​:\Users\Owner\AppData\Local\Temp
; TERM=dumb
; TMP=C​:\Users\Owner\AppData\Local\Temp
; USERDOMAIN=dellwin7
; USERNAME=Owner
; USERPROFILE=C​:\Users\Owner
; VCINSTALLDIR=C​:\Program Files\Microsoft Visual Studio 12.0\VC\
; VisualStudioVersion=12.0
; VS100COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\
; VS110COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\
; VS120COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\
; VS140COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 14.0\Common7\Tools\
; VS71COMNTOOLS=C​:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\
; VSINSTALLDIR=C​:\Program Files\Microsoft Visual Studio 12.0\
; windir=C​:\Windows
; WindowsSdkDir=C​:\Program Files\Windows Kits\8.1\
; WindowsSDK_ExecutablePath_x86=C​:\Program Files\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
; windows_tracing_flags=3
; windows_tracing_logfile=C​:\BVTBin\Tests\installpackage\csilogfile.log
; _NT_SYMBOL_PATH=symsrv*symsrv.dll*C​:\Windows\Symbols*http​://msdl.microsoft.com/download/symbols"
"12​:09​:44.9621791 AM","miniperl.exe","3772","Thread Create","SUCCESS","","Thread ID​: 5196"
"12​:09​:44.9622015 AM","miniperl.exe","2476","QuerySecurityFile","SUCCESS","C​:\p523\src\miniperl.exe","Information​: Owner, Group, DACL, SACL, Label"
"12​:09​:44.9622143 AM","miniperl.exe","2476","QueryBasicInformationFile","SUCCESS","C​:\p523\src\miniperl.exe","CreationTime​: 11/28/2015 12​:06​:08 AM, LastAccessTime​: 11/28/2015 12​:06​:08 AM, LastWriteTime​: 11/28/2015 12​:06​:08 AM, ChangeTime​: 11/28/2015 12​:06​:08 AM, FileAttributes​: A"
"12​:09​:44.9626603 AM","miniperl.exe","2476","CloseFile","SUCCESS","C​:\p523\src\miniperl.exe",""
"12​:09​:44.9627957 AM","miniperl.exe","3772","Load Image","SUCCESS","C​:\p523\src\miniperl.exe","Image Base​: 0x810000, Image Size​: 0x1cc000"
"12​:09​:44.9629213 AM","miniperl.exe","3772","Load Image","SUCCESS","C​:\Windows\System32\ntdll.dll","Image Base​: 0x77a60000, Image Size​: 0x13c000"

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

"Time of Day","Process Name","PID","Operation","Result","Path","Detail"
"11​:28​:14.3827164 PM","miniperl.exe","4704","Process Create","SUCCESS","C​:\Windows\system32\cmd.exe","PID​: 5064, Command line​: cmd.exe /x/d/c cd"
"11​:28​:14.3827507 PM","miniperl.exe","4704","QuerySecurityFile","SUCCESS","C​:\Windows\System32\cmd.exe","Information​: Owner, Group, DACL, SACL, Label"
"11​:28​:14.3827647 PM","miniperl.exe","4704","QueryBasicInformationFile","SUCCESS","C​:\Windows\System32\cmd.exe","CreationTime​: 11/20/2010 4​:29​:12 PM, LastAccessTime​: 11/20/2010 4​:29​:12 PM, LastWriteTime​: 11/20/2010 4​:29​:12 PM, ChangeTime​: 4/5/2015 5​:58​:34 AM, FileAttributes​: A"
"11​:28​:14.3832877 PM","miniperl.exe","4704","CloseFile","SUCCESS","C​:\Windows\System32\cmd.exe",""
"11​:28​:14.3978995 PM","miniperl.exe","4704","CreateFile","SUCCESS","C​:\p523\src","Desired Access​: Read Data/List Directory, Synchronize, Disposition​: Open, Options​: Directory, Synchronous IO Non-Alert, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"11​:28​:14.3979346 PM","miniperl.exe","4704","QueryDirectory","SUCCESS","C​:\p523\src\miniperl.exe","Filter​: miniperl.exe, 1​: miniperl.exe"
"11​:28​:14.3979733 PM","miniperl.exe","4704","CloseFile","SUCCESS","C​:\p523\src",""
"11​:28​:14.3983697 PM","miniperl.exe","4704","CreateFile","SUCCESS","C​:\p523\src\ext\B","Desired Access​: Read Attributes, Disposition​: Open, Options​: Open Reparse Point, Attributes​: n/a, ShareMode​: Read, Write, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"11​:28​:14.3986030 PM","miniperl.exe","4704","QueryBasicInformationFile","SUCCESS","C​:\p523\src\ext\B","CreationTime​: 4/6/2015 3​:28​:26 AM, LastAccessTime​: 11/27/2015 11​:26​:31 PM, LastWriteTime​: 11/27/2015 11​:26​:31 PM, ChangeTime​: 11/27/2015 11​:26​:31 PM, FileAttributes​: D"
"11​:28​:14.3986201 PM","miniperl.exe","4704","CloseFile","SUCCESS","C​:\p523\src\ext\B",""
"11​:28​:14.3987801 PM","miniperl.exe","4704","CreateFile","SUCCESS","C​:\p523\src\miniperl.exe","Desired Access​: Read Data/List Directory, Execute/Traverse, Read Attributes, Synchronize, Disposition​: Open, Options​: Synchronous IO Non-Alert, Non-Directory File, Attributes​: n/a, ShareMode​: Read, Delete, AllocationSize​: n/a, OpenResult​: Opened"
"11​:28​:14.3988117 PM","miniperl.exe","4704","CreateFileMapping","FILE LOCKED WITH ONLY READERS","C​:\p523\src\miniperl.exe","SyncType​: SyncTypeCreateSection, PageProtection​: PAGE_EXECUTE"
"11​:28​:14.3989528 PM","miniperl.exe","4704","CreateFileMapping","SUCCESS","C​:\p523\src\miniperl.exe","SyncType​: SyncTypeOther"
"11​:28​:14.3990275 PM","miniperl.exe","4704","QuerySecurityFile","SUCCESS","C​:\p523\src\miniperl.exe","Information​: Label"
"11​:28​:14.3991466 PM","miniperl.exe","4704","QueryNameInformationFile","SUCCESS","C​:\p523\src\miniperl.exe","Name​: \p523\src\miniperl.exe"
"11​:28​:14.3992125 PM","miniperl.exe","4704","Process Create","SUCCESS","C​:\p523\src\miniperl.exe","PID​: 2764, Command line​: ""..\..\miniperl.exe"" -le ""require 5; print qq{VER_OK}"""
"11​:28​:14.3992147 PM","miniperl.exe","2764","Process Start","SUCCESS","","Parent PID​: 4704, Command line​: ""..\..\miniperl.exe"" -le ""require 5; print qq{VER_OK}"", Current directory​: C​:\p523\src\ext\B\, Environment​:
; =​::=​::\
; =C​:=C​:\p523\src\ext\B
; =ExitCode=00000000
; ALLUSERSPROFILE=C​:\ProgramData
; APPDATA=C​:\Users\Owner\AppData\Roaming
; CommonProgramFiles=C​:\Program Files\Common Files
; COMPUTERNAME=DELLWIN7
; ComSpec=C​:\Windows\system32\cmd.exe
; DevEnvDir=C​:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\
; EMXSHELL=sh
; ExtensionSdkDir=C​:\Program Files\Microsoft SDKs\Windows\v8.1\ExtensionSDKs
; FP_NO_HOST_CHECK=NO
; Framework40Version=v4.0
; FrameworkDir=C​:\Windows\Microsoft.NET\Framework\
; FrameworkDIR32=C​:\Windows\Microsoft.NET\Framework\
; FrameworkVersion=v4.0.30319
; FrameworkVersion32=v4.0.30319
; FSHARPINSTALLDIR=C​:\Program Files\Microsoft SDKs\F#\3.1\Framework\v4.0\
; FTP_PASSIVE=1
; HOMEDRIVE=C​:
; HOMEPATH=\Users\Owner
; INCLUDE=C​:\Program Files\Microsoft Visual Studio 12.0\VC\INCLUDE;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C​:\Program Files\Windows Kits\8.1\include\shared;C​:\Program Files\Windows Kits\8.1\include\um;C​:\Program Files\Windows Kits\8.1\include\winrt;
; LIB=C​:\Program Files\Microsoft Visual Studio 12.0\VC\LIB;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\LIB;C​:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86;
; LIBPATH=C​:\Windows\Microsoft.NET\Framework\v4.0.30319;C​:\Program Files\Microsoft Visual Studio 12.0\VC\LIB;C​:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\LIB;C​:\Program Files\Windows Kits\8.1\References\CommonConfiguration\Neutral;C​:\Program Files\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\Microsoft.VCLibs\12.0\References\CommonConfiguration\neutral;
; LOCALAPPDATA=C​:\Users\Owner\AppData\Local
; LOGONSERVER=\\DELLWIN7
; NUMBER_OF_PROCESSORS=2
; OS=Windows_NT
; Path=C​:\p523\src;C​:\p523\src\win32\bin;C​:\p520\site\bin;C​:\p520\bin;C​:\sp520\c\bin;C​:\p523\site\bin;C​:\p523\bin;C​:\Windows\system32;C​:\Program Files\Microsoft Visual Studio 12.0\VC\BIN;C​:\Program Files\Windows Kits\8.1\bin\x86;C​:\Windows;C​:\Program Files\ActiveState Komodo Edit 9;C​:\Program Files\Git\bin;;;
; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
; PERL_CORE=1
; PERL_MM_USE_DEFAULT=1
; PROCESSOR_ARCHITECTURE=x86
; PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 6, GenuineIntel
; PROCESSOR_LEVEL=6
; PROCESSOR_REVISION=0f06
; ProgramData=C​:\ProgramData
; ProgramFiles=C​:\Program Files
; PROMPT=$P$G
; PSModulePath=C​:\Windows\system32\WindowsPowerShell\v1.0\Modules\
; PUBLIC=C​:\Users\Public
; PWD=C​:/p523/src/ext/B
; SESSIONNAME=Console
; SystemDrive=C​:
; SystemRoot=C​:\Windows
; TEMP=C​:\Users\Owner\AppData\Local\Temp
; TERM=dumb
; TMP=C​:\Users\Owner\AppData\Local\Temp
; USERDOMAIN=dellwin7
; USERNAME=Owner
; USERPROFILE=C​:\Users\Owner
; VCINSTALLDIR=C​:\Program Files\Microsoft Visual Studio 12.0\VC\
; VisualStudioVersion=12.0
; VS100COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\
; VS110COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 11.0\Common7\Tools\
; VS120COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\
; VS140COMNTOOLS=C​:\Program Files\Microsoft Visual Studio 14.0\Common7\Tools\
; VS71COMNTOOLS=C​:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\
; VSINSTALLDIR=C​:\Program Files\Microsoft Visual Studio 12.0\
; windir=C​:\Windows
; WindowsSdkDir=C​:\Program Files\Windows Kits\8.1\
; WindowsSDK_ExecutablePath_x86=C​:\Program Files\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
; windows_tracing_flags=3
; windows_tracing_logfile=C​:\BVTBin\Tests\installpackage\csilogfile.log
; _NT_SYMBOL_PATH=symsrv*symsrv.dll*C​:\Windows\Symbols*http​://msdl.microsoft.com/download/symbols"
"11​:28​:14.3996401 PM","miniperl.exe","2764","Thread Create","SUCCESS","","Thread ID​: 5488"
"11​:28​:14.3996761 PM","miniperl.exe","4704","QuerySecurityFile","SUCCESS","C​:\p523\src\miniperl.exe","Information​: Owner, Group, DACL, SACL, Label"
"11​:28​:14.3996937 PM","miniperl.exe","4704","QueryBasicInformationFile","SUCCESS","C​:\p523\src\miniperl.exe","CreationTime​: 11/27/2015 11​:27​:20 PM, LastAccessTime​: 11/27/2015 11​:27​:20 PM, LastWriteTime​: 11/27/2015 11​:27​:20 PM, ChangeTime​: 11/27/2015 11​:27​:20 PM, FileAttributes​: A"
"11​:28​:14.4005014 PM","miniperl.exe","4704","CloseFile","SUCCESS","C​:\p523\src\miniperl.exe",""
"11​:28​:14.4006846 PM","miniperl.exe","2764","Load Image","SUCCESS","C​:\p523\src\miniperl.exe","Image Base​: 0xa40000, Image Size​: 0x1cc000"
"11​:28​:14.4008494 PM","miniperl.exe","2764","Load Image","SUCCESS","C​:\Windows\System32\ntdll.dll","Image Base​: 0x77a60000, Image Size​: 0x13c000"

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

0001-Perl_set_caret_X-gv_fetch-with-GV_ADD-can-t-return-N.patch
From ab4e5d9a359813234cd516f8492eb0a218819b10 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Fri, 27 Nov 2015 22:29:49 -0500
Subject: [PATCH 1/2] Perl_set_caret_X gv_fetch with GV_ADD can't return NULL

The GV will be created if it doesn't exist. Remove the branch for smaller
code size.
---
 caretx.c | 130 +++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 64 insertions(+), 66 deletions(-)

diff --git a/caretx.c b/caretx.c
index 9366bc4..fe884e4 100644
--- a/caretx.c
+++ b/caretx.c
@@ -53,85 +53,83 @@
 void
 Perl_set_caret_X(pTHX) {
     GV* tmpgv = gv_fetchpvs("\030", GV_ADD|GV_NOTQUAL, SVt_PV); /* $^X */
-    if (tmpgv) {
-        SV *const caret_x = GvSV(tmpgv);
+    SV *const caret_x = GvSV(tmpgv);
 #if defined(OS2)
-        sv_setpv(caret_x, os2_execname(aTHX));
+    sv_setpv(caret_x, os2_execname(aTHX));
 #else
 #  ifdef USE_KERN_PROC_PATHNAME
-        size_t size = 0;
-        int mib[4];
-        mib[0] = CTL_KERN;
-        mib[1] = KERN_PROC;
-        mib[2] = KERN_PROC_PATHNAME;
-        mib[3] = -1;
-
-        if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0
-            && size > 0 && size < MAXPATHLEN * MAXPATHLEN) {
-            sv_grow(caret_x, size);
-
-            if (sysctl(mib, 4, SvPVX(caret_x), &size, NULL, 0) == 0
-                && size > 2) {
-                SvPOK_only(caret_x);
-                SvCUR_set(caret_x, size - 1);
-                SvTAINT(caret_x);
-                return;
-            }
+    size_t size = 0;
+    int mib[4];
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PROC;
+    mib[2] = KERN_PROC_PATHNAME;
+    mib[3] = -1;
+
+    if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0
+        && size > 0 && size < MAXPATHLEN * MAXPATHLEN) {
+        sv_grow(caret_x, size);
+
+        if (sysctl(mib, 4, SvPVX(caret_x), &size, NULL, 0) == 0
+            && size > 2) {
+            SvPOK_only(caret_x);
+            SvCUR_set(caret_x, size - 1);
+            SvTAINT(caret_x);
+            return;
         }
+    }
 #  elif defined(USE_NSGETEXECUTABLEPATH)
-        char buf[1];
-        uint32_t size = sizeof(buf);
-
-        _NSGetExecutablePath(buf, &size);
-        if (size < MAXPATHLEN * MAXPATHLEN) {
-            sv_grow(caret_x, size);
-            if (_NSGetExecutablePath(SvPVX(caret_x), &size) == 0) {
-                char *const tidied = realpath(SvPVX(caret_x), NULL);
-                if (tidied) {
-                    sv_setpv(caret_x, tidied);
-                    free(tidied);
-                } else {
-                    SvPOK_only(caret_x);
-                    SvCUR_set(caret_x, size);
-                }
-                return;
+    char buf[1];
+    uint32_t size = sizeof(buf);
+
+    _NSGetExecutablePath(buf, &size);
+    if (size < MAXPATHLEN * MAXPATHLEN) {
+        sv_grow(caret_x, size);
+        if (_NSGetExecutablePath(SvPVX(caret_x), &size) == 0) {
+            char *const tidied = realpath(SvPVX(caret_x), NULL);
+            if (tidied) {
+                sv_setpv(caret_x, tidied);
+                free(tidied);
+            } else {
+                SvPOK_only(caret_x);
+                SvCUR_set(caret_x, size);
             }
+            return;
         }
+    }
 #  elif defined(HAS_PROCSELFEXE)
-        char buf[MAXPATHLEN];
-        SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
-        /* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
-         * it is impossible to know whether the result was truncated. */
+    char buf[MAXPATHLEN];
+    SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
+    /* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
+     * it is impossible to know whether the result was truncated. */
 
-        if (len != -1) {
-            buf[len] = '\0';
-        }
+    if (len != -1) {
+        buf[len] = '\0';
+    }
 
-        /* On Playstation2 Linux V1.0 (kernel 2.2.1) readlink(/proc/self/exe)
-           includes a spurious NUL which will cause $^X to fail in system
-           or backticks (this will prevent extensions from being built and
-           many tests from working). readlink is not meant to add a NUL.
-           Normal readlink works fine.
-        */
-        if (len > 0 && buf[len-1] == '\0') {
-            len--;
-        }
+    /* On Playstation2 Linux V1.0 (kernel 2.2.1) readlink(/proc/self/exe)
+       includes a spurious NUL which will cause $^X to fail in system
+       or backticks (this will prevent extensions from being built and
+       many tests from working). readlink is not meant to add a NUL.
+       Normal readlink works fine.
+    */
+    if (len > 0 && buf[len-1] == '\0') {
+        len--;
+    }
 
-        /* FreeBSD's implementation is acknowledged to be imperfect, sometimes
-           returning the text "unknown" from the readlink rather than the path
-           to the executable (or returning an error from the readlink). Any
-           valid path has a '/' in it somewhere, so use that to validate the
-           result. See http://www.freebsd.org/cgi/query-pr.cgi?pr=35703
-        */
-        if (len > 0 && memchr(buf, '/', len)) {
-            sv_setpvn(caret_x, buf, len);
-            return;
-        }
+    /* FreeBSD's implementation is acknowledged to be imperfect, sometimes
+       returning the text "unknown" from the readlink rather than the path
+       to the executable (or returning an error from the readlink). Any
+       valid path has a '/' in it somewhere, so use that to validate the
+       result. See http://www.freebsd.org/cgi/query-pr.cgi?pr=35703
+    */
+    if (len > 0 && memchr(buf, '/', len)) {
+        sv_setpvn(caret_x, buf, len);
+        return;
+    }
 #  endif
-        /* Fallback to this:  */
-        sv_setpv(caret_x, PL_origargv[0]);
+    /* Fallback to this:  */
+    sv_setpv(caret_x, PL_origargv[0]);
 #endif
-    }
 }
 
 /*
-- 
1.9.5.msysgit.1

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

0002-move-Win32-s-X-code-to-where-all-other-OSes-X-code-l.patch
From be580dbc342ead956851b045094a06830b31a9e9 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Sat, 28 Nov 2015 00:29:17 -0500
Subject: [PATCH 2/2] move Win32's $^X code to where all other OSes' $^X code
 lives

Back when the code in perllib.c was first added in 1999, in
commit 80252599d4 the large define tree function that today in 2015 is
Perl_set_caret_X was an unremarkable single statement
http://perl5.git.perl.org/perl.git/blob/80252599d4b7fb26eec4e3a0f451b4387c5dcc19:/perl.c#l2658

Over the years Perl_set_caret_X grew and grew with OS specific code. Move
the Win32 $^X code to match how all the other OSes do it. Fix a problem
where full perl's $^X is always absolute because perl5**.dll uses
GetModuleFileNameW in perllib.c, but miniperl's $^X is always a relative
path because it's coming from libc/command prompt/make tool/make_ext.pl.
Win32 miniperl's $^X being relative causes inefficiencies in EUMM as a
relative $^X is wrong the moment chdir executes in any perl process.
EUMM contains code to search PATH and some other places to guess/figure out
the absolute patch to the current perl to write the absolute perl path
into the makefile. By making $^X absolute on all Win32 perl build variants,
this find absolute perl path code won't execute in EUMM. It also harmonizes
behavior with other OSes and between Win32 mini and full perl. See details
in RT ticket for this patch.
---
 caretx.c        |  8 ++++++++
 win32/perllib.c | 11 -----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/caretx.c b/caretx.c
index fe884e4..67b8418 100644
--- a/caretx.c
+++ b/caretx.c
@@ -126,6 +126,14 @@ Perl_set_caret_X(pTHX) {
         sv_setpvn(caret_x, buf, len);
         return;
     }
+#  elif defined(WIN32)
+    char *ansi;
+    WCHAR widename[MAX_PATH];
+    GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
+    ansi = win32_ansipath(widename);
+    sv_setpv(caret_x, ansi);
+    win32_free(ansi);
+    return;
 #  endif
     /* Fallback to this:  */
     sv_setpv(caret_x, PL_origargv[0]);
diff --git a/win32/perllib.c b/win32/perllib.c
index 0e44a24..cf7bf56 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -211,14 +211,8 @@ RunPerl(int argc, char **argv, char **env)
 {
     int exitstatus;
     PerlInterpreter *my_perl, *new_perl = NULL;
-    char *arg0 = argv[0];
-    char *ansi = NULL;
     bool use_environ = (env == environ);
 
-    WCHAR widename[MAX_PATH];
-    GetModuleFileNameW(NULL, widename, sizeof(widename)/sizeof(WCHAR));
-    argv[0] = ansi = win32_ansipath(widename);
-
 #ifdef PERL_GLOBAL_STRUCT
 #define PERLVAR(prefix,var,type) /**/
 #define PERLVARA(prefix,var,type) /**/
@@ -269,11 +263,6 @@ RunPerl(int argc, char **argv, char **env)
     }
 #endif
 
-    /* Some RTLs may want to free argv[] after main() returns. */
-    argv[0] = arg0;
-    if (ansi)
-        win32_free(ansi);
-
     PERL_SYS_TERM();
 
     return (exitstatus);
-- 
1.9.5.msysgit.1

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2015

From @bulk88

On Fri Nov 27 21​:45​:50 2015, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.23.5.

-----------------------------------------------------------------
[Please describe your issue here]

2 patches attached.

This patch came from research on EUMM commit "MM_Unix​::find_perl()
dont
repeatedly stat the same path in a loop"
Perl-Toolchain-Gang/ExtUtils-MakeMaker#245 .

I attached syscall logs before and after of how EUMM searches for the
absolute path to perl. Since EUMM commit "MM_Unix​::find_perl() dont
repeatedly stat the same path in a loop" isn't in blead, you can see
the
same file not found path "C​:\p523\src\ext\miniperl.exe" stat-ed 16
times
in a row. After the EUMM patch not in blead the bad file path would
have
been stat-ed just once. With this core patch making $^X absolute for
Win32 miniperl, the first stat will always succeed.

I will also note the patch cleans up some risky behavior in modifying libc's argv, since the C standards do not specify the type of memory that argv array, or the pointers in the array are allocated from. http​://stackoverflow.com/questions/25737434/is-argvn-writable It could all be a static global buffer, or the start of a malloc block, or a pointer into a malloc block, or a non-libc-non-malloc memory allocator (HeapAlloc and friends with a random private heap pool). Previous the original pointer from libc was saved and then restored.

Here is an excerpt from a commit that mentions the high risk behavior http​://perl5.git.perl.org/perl.git/commitdiff/aa2b96eccca93a6fe7c95af71c0b4a027561512b


-
-#ifndef __BORLANDC__
- /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
- * want to free() argv after main() returns. As luck would have it,
- * Borland's CRT does the right thing to argv[0] already. */
+ OSVERSIONINFO osver;
  char szModuleName[MAX_PATH];
+ char *arg0 = argv[0];
+ char *ansi = NULL;


This risky code of patching argv is removed with this patch. Win32 perl libperl embedders will probably see a change in $^X from relative to absolute since RunPerl with its former GetModuleFileNameW is executed only by p5p's perl.exe, not embedder's .exe. I dont see a problem by this change since BSD, OSX, and Linux all ignore libc's argv[0] and use OS specific ways to set $^X to be absolute in Perl_set_caret_X. Since BSD/OSX/Linux ignore argv[0] for $^X now, I think the examples in http​://perldoc.perl.org/perlembed.html#Maintaining-multiple-interpreter-instances are broken.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2015

From @tonycoz

On Fri Nov 27 21​:45​:50 2015, bulk88 wrote​:

2 patches attached.

This patch came from research on EUMM commit "MM_Unix​::find_perl()
dont
repeatedly stat the same path in a loop"
Perl-Toolchain-Gang/ExtUtils-MakeMaker#245 .

I attached syscall logs before and after of how EUMM searches for the
absolute path to perl. Since EUMM commit "MM_Unix​::find_perl() dont
repeatedly stat the same path in a loop" isn't in blead, you can see
the
same file not found path "C​:\p523\src\ext\miniperl.exe" stat-ed 16
times
in a row. After the EUMM patch not in blead the bad file path would
have
been stat-ed just once. With this core patch making $^X absolute for
Win32 miniperl, the first stat will always succeed.

Thanks, applied as eb4e1ba and 7175d76.

Tony

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2015

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

From @khwilliamson

Thank you for submitting this report. You have helped make Perl better.
 
With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved.

Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

@khwilliamson - Status changed from 'pending release' to 'resolved'

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

1 participant