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

Process.create with startup_info lead to Process finished with exit code -1073740791 (0xC0000409) on Windows 10 #30

Closed
CAMOBAP opened this issue Jun 8, 2020 · 9 comments

Comments

@CAMOBAP
Copy link

CAMOBAP commented Jun 8, 2020

Description

Process.create with startup_info lead to Process finished with exit code -1073740791 (0xC0000409), without startup_info it works as expected.

It starts happens relatively recently, maybe related to some update of Windows OS

Under debugger, I have reached the last line of code after which crash happens

Gem Version

0.8.3

Windows Version

Windows 10,

more details from `systeminfo` command


Host Name:                 MSEDGEWIN10
OS Name:                   Microsoft Windows 10 Enterprise Evaluation
OS Version:                10.0.17134 N/A Build 17134
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          
Registered Organization:   Microsoft
Product ID:                00329-20000-00001-AA244
Original Install Date:     4/25/2018, 8:48:06 AM
System Boot Time:          6/8/2020, 12:58:22 PM
System Manufacturer:       innotek GmbH
System Model:              VirtualBox
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 70 Stepping 1 GenuineIntel ~2295 Mhz
BIOS Version:              innotek GmbH VirtualBox, 12/1/2006
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory:     4,083 MB
Available Physical Memory: 1,627 MB
Virtual Memory: Max Size:  4,787 MB
Virtual Memory: Available: 2,211 MB
Virtual Memory: In Use:    2,576 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              \\MSEDGEWIN10
Hotfix(s):                 11 Hotfix(s) Installed.
                           [01]: KB4552929
                           [02]: KB4346084
                           [03]: KB4485449
                           [04]: KB4486153
                           [05]: KB4497398
                           [06]: KB4509094
                           [07]: KB4512576
                           [08]: KB4523203
                           [09]: KB4537759
                           [10]: KB4540724
                           [11]: KB4556807
Network Card(s):           4 NIC(s) Installed.
                           [01]: Intel(R) PRO/1000 MT Desktop Adapter
                                 Connection Name: Ethernet
                                 DHCP Enabled:    Yes
                                 DHCP Server:     N/A
                                 IP address(es)
                           [02]: Hyper-V Virtual Ethernet Adapter
                                 Connection Name: vEthernet (Default Switch)
                                 DHCP Enabled:    Yes
                                 DHCP Server:     255.255.255.255
                                 IP address(es)
                                 [01]: 172.26.116.81
                                 [02]: fe80::9df6:3a96:446a:6dfa
                           [03]: Hyper-V Virtual Ethernet Adapter
                                 Connection Name: vEthernet (MySwitch)
                                 DHCP Enabled:    Yes
                                 DHCP Server:     10.0.2.2
                                 IP address(es)
                                 [01]: 10.0.2.15
                                 [02]: fe80::a068:4c16:5444:765c
                           [04]: Hyper-V Virtual Ethernet Adapter
                                 Connection Name: vEthernet (nat)
                                 DHCP Enabled:    Yes
                                 DHCP Server:     255.255.255.255
                                 IP address(es)
                                 [01]: 172.20.144.1
                                 [02]: fe80::2999:38a9:47f7:10e3
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

Replication Case

The minimal program to reproduce

require "win32/process"

_, stdout_write = IO.pipe

args = {
  command_line: 'echo "Hello World!"',
  startup_info: {
    stdout: stdout_write,
  }
}

Process.create args
@djberg96
Copy link
Collaborator

djberg96 commented Jun 9, 2020

Isn't the first argument returned from IO.pipe the input pipe?

@CAMOBAP
Copy link
Author

CAMOBAP commented Jun 9, 2020

@djberg96 you are right, updated code sample:

require "win32/process"

_, stdout_write = IO.pipe

args = {
  command_line: 'echo "Hello World!"',
  startup_info: {
    stdout: stdout_write,
  }
}

Process.create args

@djberg96
Copy link
Collaborator

djberg96 commented Jun 9, 2020

Hm, I can't get it to work either. It's been a long time since I tried it, and I can see where we at least attempt to handle it:

https://github.com/chef/win32-process/blob/ffi/lib/win32/process.rb#L563-L598

I'm not immediately certain why it's failing.

@CAMOBAP
Copy link
Author

CAMOBAP commented Jun 9, 2020

@djberg96 I'm open to help if you have any idea (direction) what to investigate/check I will proceed.

According to https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle API of this method wasn't changed

I have found a similar issue in node world nodejs/node#6369 , is it possible that we faced with the same issue?

@djberg96
Copy link
Collaborator

djberg96 commented Jun 9, 2020

I don't think I understand the issue well enough. All I say is that we do check the result of get_osfhandle function. Beyond that, I don't know.

@CAMOBAP
Copy link
Author

CAMOBAP commented Jun 9, 2020

I'm not sure if this will help but, initially, we observed this problem on Github Actions

I have diffed those configuration and didn't found any significant update

More CI runs can be found here:

@djberg96
Copy link
Collaborator

djberg96 commented Jun 9, 2020

@CAMOBAP Hopefully someone from the chef team can help you, because I just don't know. One thing you could try is to see if equivalent C code works for you. If it does, then start inspecting the internals, such as the STARTINFO struct, to see what might be different.

@CAMOBAP
Copy link
Author

CAMOBAP commented Jun 9, 2020

@djberg96 thanks for giving a direction

@djberg96
Copy link
Collaborator

djberg96 commented Jun 9, 2020

@CAMOBAP I tried this:

#include <windows.h>
#include <stdio.h>

int main(){
  STARTUPINFOA s1;
  STARTUPINFOW s2;

  printf("sizeof(A): %i\n", sizeof(STARTUPINFOA)); # 68
  printf("sizeof(W): %i\n", sizeof(STARTUPINFOW)); # 68

  return 0;
}

I even note this size in the constants.rb file. But in my tests the Ruby code STARTUPINFO.size comes back as 104. Maybe that's a clue?

Edit: Or maybe it's a 32bit vs 64bit thing on my end.

@CAMOBAP CAMOBAP closed this as completed Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants