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
unexpected exit in open3() on win32 #9214
Comments
From adavies@ptc.comCreated by adavies@ptc.comIPC::Open3::open3() appears to exit on Win32 when STDOUT is redirected D:\>cat open3_testcase.pl require IPC::Open3;
require IO::File;
my $cmd = "find.exe ."; # a random command to run
*CMD_ERR = IO::File->new_tmpfile;
print "start $^X\n";
my $pid = eval {
IPC::Open3::open3(undef, \*CMD_OUT, ">&CMD_ERR", $cmd);
};
$@ and die "failed to run $cmd\n$@";
print "end $pid\n";
By placing print statements into IPC::Open3, it appears to be exiting
Any idea what's happening here? Is it a bug? Cheers, alex. Perl Info
|
From @jkeenanIs there anyone on a supported version of Win32 who could take a look at Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @bulk88Reproduced with 5.12.2 and some blead of 5.19.4 C:\Documents and Settings\Administrator\Desktop>perl n1.pl C:\Documents and Settings\Administrator\Desktop>n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop>perl n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop>perl 0v C:\Documents and Settings\Administrator\Desktop>perl -v This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-t Copyright 1987-2010, Larry Wall Binary build 1204 [294330] provided by ActiveState http://www.ActiveState.com Perl may be copied only under the terms of either the Artistic License or the Complete documentation for Perl, including FAQ lists, should be found on C:\Documents and Settings\Administrator\Desktop> C:\Documents and Settings\Administrator\Desktop>perl n1.pl C:\Documents and Settings\Administrator\Desktop>n1.pl C:\Documents and Settings\Administrator\Desktop>n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop>perl -v This is perl 5, version 19, subversion 4 (v5.19.4) built for MSWin32-x86-multi-t Copyright 1987-2013, Larry Wall Perl may be copied only under the terms of either the Artistic License or the Complete documentation for Perl, including FAQ lists, should be found on C:\Documents and Settings\Administrator\Desktop> C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop> C:/p519/lib/IO/Handle.pm sub fdopen { if (ref($fd) && "".$fd =~ /GLOB\(/o) { open($io, _open_mode_string($mode) . '&' . $fd)<<<<<<<<<<<<<<<<<LINE 379 some debugging output, i edited the file assoc in registry to include -d to make the below main::(C:\Documents and Settings\Administrator\Desktop\n1.pl:74): C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop> Changing the last print to a warn does print to console, so the "unexpected exit" conclusion is a confused ticket reporter. Instead redirecting or handle closure is happening in the print call. IDK which, stdio and this whole ticket beyond my knowledge but I'm replying because there is nobody else to investigate it. use Devel::Peek 'Dump'; C:\Documents and Settings\Administrator\Desktop>n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop>type t.txt C:\Documents and Settings\Administrator\Desktop> This is all I figured so far. -- |
From @bulk88On Tue Mar 11 00:36:40 2014, bulk88 wrote:
hacking up fdopen in IO::Handle sub fdopen { if (ref($fd) && "".$fd =~ /GLOB\(/o) { On no redirect run. C:\Documents and Settings\Administrator\Desktop>n1.pl C:\Documents and Settings\Administrator\Desktop> With redirect. C:\Documents and Settings\Administrator\Desktop>n1.pl > t.txt oserr 5 is "ERROR_ACCESS_DENIED 5 (0x5) Access is denied." It came from the following C call stack /* use the file handle to get all the info about the file
Which tickles down to pp_open, which returns undef in PP land. -- |
From @bulk88Broke issue down to, there are no crashes DebugBreak() hits below C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>perl n1.pl C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>n1.pl C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>perl n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS> void #this is n1.pl for THIS POST ONLY -- |
From @bulk88To debug further, I ask how does cmd.exe start "n1.pl > t.txt"? shell32.dll!_ShellExecuteExW@4() Notice this isn't CreateProcess but a "you cant specify child handles" derivative. What was passed To ShellExecuteEx? SHELLEXECUTEINFO struct 0x002CFB00 0000003c <...size (wchar_t *)0x002D48E8 (wchar_t *)0x002edf00 (wchar_t *)0x4ad34460 break up the bitfield SEE_MASK_NOCLOSEPROCESS (0x00000040) flag 0x00080000 is undocumented http://www.reactos.org/archives/public/ros-diffs/2013-March/048151.html http://doxygen.reactos.org/df/dd3/shellapi_8h_source.html#l00050 0x00040000 is the last documented undocumented flag section "Pass arbitrary data to a child process!" in http://www.catch22.net/tuts/undocumented-createprocess#undoc might be relevent somehow to this bug (a WAG) lets see where ShellExecuteExW takes us
to be continued -- |
From @bulk88On Tue Mar 11 19:09:27 2014, bulk88 wrote:
lets see where ShellExecuteExW takes us kernel32.dll!_CreateProcessW@40() 0x002CEFC8 002f46e4 äF/.lpApplicationName, 0x002f46e4 "C:\p519\bin\perl.exe" 0x002CEFDC 04000400 .... DWORD dwCreationFlags, CREATE_DEFAULT_ERROR_MODE lpStartupInfo 0x002F5D48 00000044 D... ShellExecuteExW returns 1 success. command line file assoc launched and redirect perl is "C:\p519\bin\perl.exe" "C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS\n1.pl" important thing is no > t.txt in there So lets research the handle types. I used some crude code to do it. n1.pl #!/usr/bin/perl -w void sNtQueryVolumeInformationFile NtQueryVolumeInformationFile = GetProcAddress(ntdll, "NtQueryVolumeInformationFile"); if(!DuplicateHandle( Status = NtQueryVolumeInformationFile(hFile, if(!CreatePipe(&read, &write, NULL, 1024)) C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>n1.pl C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>n1.pl > t.txt C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>perl n1.pl C:\Documents and Settings\Administrator\Desktop\lxs\Local-XS>perl n1.pl > t.txt GLR Type FILE_TYPE_DISK NtQVIF 0xC0000008 0x00000000 NTType -- |
@bulk88 what did we learn? You left us on a cliff hanger! |
Migrated from rt.perl.org#50374 (status was 'open')
Searchable as RT50374$
The text was updated successfully, but these errors were encountered: