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

Spawned wsl.exe processes by a windows native nodejs child_process spawn command are not dying #12159

Open
1 of 2 tasks
iongion opened this issue Oct 12, 2024 · 7 comments
Open
1 of 2 tasks

Comments

@iongion
Copy link

iongion commented Oct 12, 2024

Windows Version

Microsoft Windows [Version 10.0.22631.4317]

WSL Version

2.1.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.146.1-microsoft-standard-WSL2

Distro Version

Ubuntu 24.04

Other Software

I am using a custom application, developed by myself - https://container-desktop.com

Because on Windows, I cannot use WSL 2 unix domain sockets directly, I need to relay them somehow.
My choice is to use socat binary in Ubuntu and use stdin and stdout to relay from a unix socket, /var/run/docker.sock
I created a nodejs server that listens to a named pipe and spawns socat processes inside WSL to write to the socket and read back from it.
My invocation arguments for spawning the WSL socat binary look like this:

 [
              "--distribution",
              "Ubuntu-24.04",
              "--exec",
              "socat",
              "-v",
              "-d",
              "-d",
              "-d",
              `UNIX-CONNECT:/var/run/docker.sock,retry,forever`,
              "STDIO"
]

After several calls, I see a lot of these accumulating

Image

And behind each are various like these

Image

In linux, ps aux shows that socat is dead, but a lot of these accumulated

root      342045  0.0  0.0   2320   144 ?        S    19:37   0:00 /init
root      342054  0.0  0.0   2320   144 ?        S    19:37   0:00 /init
root      342076  0.0  0.0   2320   144 ?        S    19:37   0:00 /init
root      342085  0.0  0.0   2320   144 ?        S    19:37   0:00 /init
root      342088  0.0  0.0   2320   144 ?        S    19:37   0:00 /init
root      342591  0.0  0.0   2320   144 ?        S    19:38   0:00 /init
root      342609  0.0  0.0   2320   144 ?        S    19:38   0:00 /init
root      342618  0.0  0.0   2320   144 ?        S    19:38   0:00 /init
root      342621  0.0  0.0   2320   144 ?        S    19:38   0:00 /init
root      342636  0.0  0.0   2320   144 ?        S    19:38   0:00 /init
root      342851  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342854  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342880  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342886  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342889  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342898  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342901  0.0  0.0   2320   144 ?        S    19:39   0:00 /init
root      342957  0.0  0.0   2320   144 ?        S    19:40   0:00 /init
root      342960  0.0  0.0   2320   144 ?        S    19:40   0:00 /init
root      343447  0.0  0.0   2320   144 ?        S    19:42   0:00 /init
root      343460  0.0  0.0   2320   144 ?        S    19:42   0:00 /init
root      343463  0.0  0.0   2320   144 ?        S    19:42   0:00 /init
root      343668  0.0  0.0   2320   144 ?        S    19:43   0:00 /init
root      343776  0.0  0.0   2320   144 ?        S    19:44   0:00 /init
root      343782  0.0  0.0   2320   144 ?        S    19:44   0:00 /init
root      344186  0.0  0.0   2320   144 ?        S    19:46   0:00 /init
root      344200  0.0  0.0   2320   144 ?        S    19:46   0:00 /init
root      344316  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344362  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344365  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344368  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344395  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344404  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344548  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344560  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344568  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344571  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344586  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344595  0.0  0.0   2320   144 ?        S    19:47   0:00 /init
root      344778  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344789  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344804  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344834  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344837  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344843  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344849  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344868  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344871  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344883  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      344901  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345063  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345117  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345120  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345123  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345133  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345136  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345145  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345148  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345151  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345229  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345232  0.0  0.0   2320   144 ?        S    19:48   0:00 /init
root      345235  0.0  0.0   2320   144 ?        S    19:48   0:00 /init

Repro Steps

  1. Create a named pipe server and run it in nodejs (node.exe)
  2. For each client connection, spawn a new socat process as above, bind to clientSocket data event and write the chunk to socat STDIN, read back from socat STDOUT and write the data to the clientSocket
  3. Close the spawned socat process using clientSocketProcess.kill() in nodejs

You will notice, socat is killed in WSL, but the weird wsl wrappers are still there and keep accumulating.

Expected Behavior

I expect the related processes to die once the linux socat has exited.

Actual Behavior

Too many init processes running in WSL distro and also too many wslhost.exe and conhost.exe pairs

Diagnostic Logs

WslLogs-2024-10-12_21-18-45.zip

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@iongion
Copy link
Author

iongion commented Oct 12, 2024

I have attached the logs as instructed with the issue reproduced.

@iongion iongion changed the title Spawned nodejs processes with wsl.exe are not dying Spawned wsl.exe processes by a windows native nodejs child_process spawn command are not dying Oct 12, 2024
Copy link

The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

Diagnostic information
Issue was edited and new log file was found: https://github.com/user-attachments/files/17351199/WslLogs-2024-10-12_21-14-42.zip
.wslconfig found
	Custom kernel command line found: 'ipv6.disable=1 cgroup_no_v1=all'
Detected appx version: 2.1.5.0
Found no WSL traces in the logs

Copy link

The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
	Custom kernel command line found: 'ipv6.disable=1 cgroup_no_v1=all'
Detected appx version: 2.1.5.0
Found no WSL traces in the logs

@iongion
Copy link
Author

iongion commented Oct 12, 2024

Copy link

Diagnostic information
.wslconfig found
	Custom kernel command line found: 'ipv6.disable=1 cgroup_no_v1=all'
Detected appx version: 2.1.5.0

Copy link

Diagnostic information
Issue was edited and new log file was found: https://github.com/user-attachments/files/17351229/WslLogs-2024-10-12_21-18-45.zip
.wslconfig found
	Custom kernel command line found: 'ipv6.disable=1 cgroup_no_v1=all'
Detected appx version: 2.1.5.0

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

1 participant