microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.89k stars 797 forks source link

Insufficient system resources exist to complete the requested service. #5231

Open ioweb-gr opened 4 years ago

ioweb-gr commented 4 years ago

Please fill out the below information:

Microsoft Windows [Version 10.0.19041.264]

Trying to execute kali linux in WSL2 results into an error

The error is Insufficient system resources exist to complete the requested service. however the instance should run correctly. Rebooting solves the issue

Restarting the HV Host Service seems to work too.

jozsefsallai commented 3 years ago

A workaround that seems to do the trick every time for me is reducing my RAM usage below 50%, then running wsl --shutdown, restarting HvHost, and then trying to start WSL2 again.

mati865 commented 3 years ago

@ggogel just today it happened for me on 2700X with 70% free memory out of 16 GiB. Went away after restarting.

Since all reports here mention Ryzen CPU, I think there could be Hyper-V issue with SVM support.

ggogel commented 3 years ago

@mati865 well I've seen this issue with the new Docker Desktop WSL for v2004. When the error was thrown I observed a RAM usage of 60%. After clearing it up down to 45%, suddenly Docker Desktop started normally.

cristianuibar commented 3 years ago

Just had the same issue on a Ryzen 4800h with 16G of RAM running a Windows 10 Pro v2004 build 19041.388. I am using Ubuntu mostly for git/gcloud/kubectl tools. Not using Docker or any webserver for local dev.

Adding the .wslconfig file in my home dir C:\Users\<username>\.wslconfig fixed it for me (no OS restart needed) with the following content:

[wsl2]
memory=4GB
processors=2

The issue just started to appear today, worked perfectly until today for me. I was seeing this error when trying to lunch Ubuntu (version 20.04.1 LTS is installed) via the Start menu.

otterDeveloper commented 3 years ago

Same Issue trying to launch Ubuntu on WSL2 Windows 10 2004 19041.388 Ryzen 5 2600X, 16GB RAM (62% utilization)

mbledkowski commented 3 years ago

Ryzen 5 2500U + 8 GB RAM (1.1 GB reserved for integrated GPU)

Creating .wslconfig file, and assigning only one processor worked for me. When i set "processors" value to any number larger than 1, error continues to occur. "memory" value do not have any impact on this, so I removed it.

.wslconfig:

[wsl2]
processors=1 # Limits VM virtual processors in WSL 2
beverneus commented 3 years ago

Ryzen 5 3500U + 8 GB RAM (2GB for integraded GPU)

It worked after limiting the processors value to 1, any higher and it doesn't work

.wslconfig:

[wsl2]
processors=1 # Makes the WSL 2 VM use one virtual processors
dranzerashi commented 3 years ago

Then 16 threads and 32Gb of RAM. This issue #5240 was very similar. Try creating a .wslconfig file and reduce the numbers of processors and RAM used for the WSL2 VM.

Same issue on ryzen 9 4900H, 16GB ram (SVM turned on). This works created the .wslconfig with Ram and processor values set to 4GB and 2 cores, restart the terminal and run wsl again.

wgbcamp commented 3 years ago

Same issue happening here a few times over the past several days on a Ryzen 7 1700 and 16GB ram on windows 10 2004. Terminating ubuntu 18.04 in powershell and starting it up again seems to have solved the problem temporarily.

niklassheth commented 3 years ago

I am also experiencing this problem on a Ryzen 5 1600 system with 16GB of RAM.

benhillis commented 3 years ago

What does https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo return on your machines?

petrroll commented 3 years ago
Hardware information:
wProcessorArchitecture: 0
wReserved: 0
dwPageSize: 4096
lpMinimumApplicationAddress: 00010000
lpMaximumApplicationAddress: 7FFEFFFF
dwActiveProcessorMask: 65535
dwNumberOfProcessors: 16
dwProcessorType: 586
dwAllocationGranularity: 65536
wProcessorLevel: 23
wProcessorRevision: 28928
// GetSystemInfoCpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

int main()
{
    SYSTEM_INFO siSysInfo;

    // Copy the hardware information to the SYSTEM_INFO structure. 
    GetSystemInfo(&siSysInfo);

    // Display the contents of the SYSTEM_INFO structure. 
    printf("Hardware information: \n");

    std::cout << "wProcessorArchitecture" << ": " << siSysInfo.wProcessorArchitecture << std::endl;
    std::cout << "wReserved" << ": " << siSysInfo.wReserved << std::endl;
    std::cout << "dwPageSize" << ": " << siSysInfo.dwPageSize << std::endl;
    std::cout << "lpMinimumApplicationAddress" << ": " << siSysInfo.lpMinimumApplicationAddress << std::endl;
    std::cout << "lpMaximumApplicationAddress" << ": " << siSysInfo.lpMaximumApplicationAddress << std::endl;
    std::cout << "dwActiveProcessorMask" << ": " << siSysInfo.dwActiveProcessorMask << std::endl;
    std::cout << "dwNumberOfProcessors" << ": " << siSysInfo.dwNumberOfProcessors << std::endl;
    std::cout << "dwProcessorType" << ": " << siSysInfo.dwProcessorType << std::endl;
    std::cout << "dwAllocationGranularity" << ": " << siSysInfo.dwAllocationGranularity << std::endl;
    std::cout << "wProcessorLevel" << ": " << siSysInfo.wProcessorLevel << std::endl;
    std::cout << "wProcessorRevision" << ": " << siSysInfo.wProcessorRevision << std::endl;

    std::cout << std::flush;
}
benhillis commented 3 years ago

Shoot that one didn't have the value I care about. Could you query SystemBasicInfo with https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation?

petrroll commented 3 years ago
NtQuerySystemInformation:
NumberOfProcessors: 16

Please don't judge my Cpp/Win32 skills :D.

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include "GetSystemInfoCpp.h"
#include "Winternl.h"
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "ntdll.lib")

void GetSystemInfo()
{
    SYSTEM_INFO siSysInfo;

    // Copy the hardware information to the SYSTEM_INFO structure. 
    GetSystemInfo(&siSysInfo);

    // Display the contents of the SYSTEM_INFO structure. 
    printf("GetSystemInfo: \n");

    std::cout << "wProcessorArchitecture" << ": " << siSysInfo.wProcessorArchitecture << std::endl;
    std::cout << "wReserved" << ": " << siSysInfo.wReserved << std::endl;
    std::cout << "dwPageSize" << ": " << siSysInfo.dwPageSize << std::endl;
    std::cout << "lpMinimumApplicationAddress" << ": " << siSysInfo.lpMinimumApplicationAddress << std::endl;
    std::cout << "lpMaximumApplicationAddress" << ": " << siSysInfo.lpMaximumApplicationAddress << std::endl;
    std::cout << "dwActiveProcessorMask" << ": " << siSysInfo.dwActiveProcessorMask << std::endl;
    std::cout << "dwNumberOfProcessors" << ": " << siSysInfo.dwNumberOfProcessors << std::endl;
    std::cout << "dwProcessorType" << ": " << siSysInfo.dwProcessorType << std::endl;
    std::cout << "dwAllocationGranularity" << ": " << siSysInfo.dwAllocationGranularity << std::endl;
    std::cout << "wProcessorLevel" << ": " << siSysInfo.wProcessorLevel << std::endl;
    std::cout << "wProcessorRevision" << ": " << siSysInfo.wProcessorRevision << std::endl;

    std::cout << std::flush;
}

void NtQuerySystemInfo() 
{
    printf("NtQuerySystemInformation: \n");
    _SYSTEM_BASIC_INFORMATION inf;
    ULONG resultSize = 0;

    if (!NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, &inf, sizeof(inf), &resultSize))) {
        std::cout << "ERROR" << std::endl;
    }
    std::cout << "NumberOfProcessors" << ": " << (int)inf.NumberOfProcessors << std::endl;
}

int main()
{
    //GetSystemInfo();
    NtQuerySystemInfo();
}
otterDeveloper commented 3 years ago
NtQuerySystemInformation:
NumberOfProcessors: 12
benhillis commented 3 years ago

Thanks, the values I'm more interested are PageSize and NumberOfPhysicalPages.

petrroll commented 3 years ago

That's in which class? Would probably be better if you provided us with the exact code you want us to run the query the specific information.

benhillis commented 3 years ago

SystemBasicInformation

petrroll commented 3 years ago

The header on my machine specifies _SYSTEM_BASIC_INFORMATION struct as not containing any such fields... I might be misunderstanding how to properly query this NT API, tho. My knowledge in this field is... was non-existent as of 5 minutes ago :).

typedef struct _SYSTEM_BASIC_INFORMATION {
    BYTE Reserved1[24];
    PVOID Reserved2[4];
    CCHAR NumberOfProcessors;
} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
benhillis commented 3 years ago

Interesting. I didn't realize that struct wasn't public. Here's one that somebody reverse-engineered: https://processhacker.sourceforge.io/doc/struct___s_y_s_t_e_m___b_a_s_i_c___i_n_f_o_r_m_a_t_i_o_n.html

petrroll commented 3 years ago

nvm, got a documented version https://github.com/qilingframework/qiling/pull/358

petrroll commented 3 years ago
NtQuerySystemInformation:
TimerResolution: 156250
PageSize: 4096
NumberOfPhysicalPages: 4181605
LowestPhysicalPageNumber: 1
HighestPhysicalPageNumber: 4322175
AllocationGranularity: 65536
MinimumUserModeAddress: 65536
MaximumUserModeAddress: 2147418111
ActiveProcessorsAffinityMask: 65535
NumberOfProcessors: 16
TimerResolution: 156250
TimerResolution: 156250
// GetSystemInfoCpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include "GetSystemInfoCpp.h"
#include "Winternl.h"
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "ntdll.lib")

void GetSystemInfo()
{
    SYSTEM_INFO siSysInfo;

    // Copy the hardware information to the SYSTEM_INFO structure. 
    GetSystemInfo(&siSysInfo);

    // Display the contents of the SYSTEM_INFO structure. 
    printf("GetSystemInfo: \n");

    std::cout << "wProcessorArchitecture" << ": " << siSysInfo.wProcessorArchitecture << std::endl;
    std::cout << "wReserved" << ": " << siSysInfo.wReserved << std::endl;
    std::cout << "dwPageSize" << ": " << siSysInfo.dwPageSize << std::endl;
    std::cout << "lpMinimumApplicationAddress" << ": " << siSysInfo.lpMinimumApplicationAddress << std::endl;
    std::cout << "lpMaximumApplicationAddress" << ": " << siSysInfo.lpMaximumApplicationAddress << std::endl;
    std::cout << "dwActiveProcessorMask" << ": " << siSysInfo.dwActiveProcessorMask << std::endl;
    std::cout << "dwNumberOfProcessors" << ": " << siSysInfo.dwNumberOfProcessors << std::endl;
    std::cout << "dwProcessorType" << ": " << siSysInfo.dwProcessorType << std::endl;
    std::cout << "dwAllocationGranularity" << ": " << siSysInfo.dwAllocationGranularity << std::endl;
    std::cout << "wProcessorLevel" << ": " << siSysInfo.wProcessorLevel << std::endl;
    std::cout << "wProcessorRevision" << ": " << siSysInfo.wProcessorRevision << std::endl;

    std::cout << std::flush;
}

// courtesy of: https://github.com/qilingframework/qiling/pull/358
typedef struct _SYSTEM_BASIC_INFORMATION2
{
    ULONG Reserved;
    ULONG TimerResolution;
    ULONG PageSize;
    ULONG NumberOfPhysicalPages;
    ULONG LowestPhysicalPageNumber;
    ULONG HighestPhysicalPageNumber;
    ULONG AllocationGranularity;
    ULONG_PTR MinimumUserModeAddress;
    ULONG_PTR MaximumUserModeAddress;
    ULONG_PTR ActiveProcessorsAffinityMask;
    CCHAR NumberOfProcessors;
} SYSTEM_BASIC_INFORMATION2, * PSYSTEM_BASIC_INFORMATION2;

void NtQuerySystemInfo() 
{
    printf("NtQuerySystemInformation: \n");
    _SYSTEM_BASIC_INFORMATION2 inf;
    ULONG resultSize = 0;

    if (!NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, &inf, sizeof(inf), &resultSize))) {
        std::cout << "ERROR" << std::endl;
    }
    std::cout << "TimerResolution" << ": " << inf.TimerResolution << std::endl;
    std::cout << "PageSize" << ": " << inf.PageSize << std::endl;
    std::cout << "NumberOfPhysicalPages" << ": " << inf.NumberOfPhysicalPages << std::endl;
    std::cout << "LowestPhysicalPageNumber" << ": " << inf.LowestPhysicalPageNumber << std::endl;
    std::cout << "HighestPhysicalPageNumber" << ": " << inf.HighestPhysicalPageNumber << std::endl;
    std::cout << "AllocationGranularity" << ": " << inf.AllocationGranularity << std::endl;
    std::cout << "MinimumUserModeAddress" << ": " << inf.MinimumUserModeAddress << std::endl;
    std::cout << "MaximumUserModeAddress" << ": " << inf.MaximumUserModeAddress << std::endl;
    std::cout << "ActiveProcessorsAffinityMask" << ": " << inf.ActiveProcessorsAffinityMask << std::endl;
    std::cout << "NumberOfProcessors" << ": " << (int)inf.NumberOfProcessors << std::endl;
    std::cout << "TimerResolution" << ": " << inf.TimerResolution << std::endl;
    std::cout << "TimerResolution" << ": " << inf.TimerResolution << std::endl;

}

int main()
{
    //GetSystemInfo();
    NtQuerySystemInfo();
}
otterDeveloper commented 3 years ago
NtQuerySystemInformation:
TimerResolution: 156250
PageSize: 4096
NumberOfPhysicalPages: 4181625
LowestPhysicalPageNumber: 1
HighestPhysicalPageNumber: 4322175
AllocationGranularity: 65536
MinimumUserModeAddress: 65536
MaximumUserModeAddress: 2147418111
ActiveProcessorsAffinityMask: 4095
NumberOfProcessors: 12
TimerResolution: 156250
TimerResolution: 156250

or in hex:

Size : 0x2c Status                              : 0x00000000
ActiveProcessorsAffinityMask    : 0x00000FFF
AllocationGranularity                   : 0x00010000
HighestPhysicalPageNumber               : 0x0041F37F
LowestPhysicalPageNumber                : 0x00000001
MaximumUserModeAddress                  : 0x7FFEFFFF
MinimumUserModeAddress                  : 0x00010000
NumberOfPhysicalPages                   : 0x003FCE79
NumberOfProcessors                              : 0x0000000C
PageSize                                                : 0x00001000
TimerResolution                                 : 0x0002625A
benhillis commented 3 years ago

Thanks, that's helpful but unfortunately I'm going to have to keep digging...

rbywater commented 3 years ago

Just another "me too" also with a Ryzen 5 1600, 16Gb RAM. Event viewer has this in the Hyper-V-Worker when this happens: Failed to create partition: Insufficient system resources exist to complete the requested service. (0x800705AA). if that helps. Guessing something to do with Hyper-V is broken on Ryzens at the moment?

ggogel commented 3 years ago

Just wanted to report back that I didn't receive the error anymore on three different Ryzen machines: 1700X 16GB 2600 16GB 3600XT 32GB

The only time I experienced this issue was when I had a high RAM usage. So my guess is that the service wants allocate either more logical cores or RAM than the system has available. Maybe some users have migrated a configuration file (.wslconfig ?) over to a machine with less resources or the system has some default settings which exceeds the limit.

According to this documentation https://docs.microsoft.com/en-us/windows/wsl/wsl-config#wsl-2-settings the default value for memory is 80% of total memory and processors is "the same number of processors on Windows". I suppose that also the size of the swap file can cause issues on some systems.

Ocramoi commented 3 years ago

Also having this problem. Win10 2004, AMD Ryzen 5 3500U, 12GB of RAM.

midnightexigent commented 3 years ago

Just had the same issue on my laptop Ryzen 5 2500U 8GB RAM

Managed to fix it by plugging in the charger and restarting my laptop.

aexvir commented 3 years ago

Chiming here as well

AlexHunterCodes commented 3 years ago

Same issue for me too on the following configuration. Re-logging/restarting didn't make any difference for me. Using the .wslconfig workaround, set to 8GB on 2 processors to play it safe. This also fixes RPC errors from Docker Desktop during startup when configured with the WSL2 backend.

Erza commented 3 years ago

Same issue here on a Ryzen 5 1600, Windows 10 2004, 16 GB RAM

Seems like this issue is mainly affecting Ryzen based CPU's

rupeshknn commented 3 years ago

Same issue here on a Ryzen 5 1600, Windows 10 2004, 16 GB RAM

Seems like this issue is mainly affecting Ryzen based CPU's

yes, that seems to be the case

schrummy14 commented 3 years ago

Ryzen 7 1700x 16 GB RAM

I can't limit the number of processors due to me needing multiple cores for my work

benhillis commented 3 years ago

Thanks for your patience, we're still investigating how to better support CPUs with many cores.

kode54 commented 3 years ago

Ryzen 7 2700 16 GB RAM

GetSystemInfo:
wProcessorArchitecture: 0
wReserved: 0
dwPageSize: 4096
lpMinimumApplicationAddress: 00010000
lpMaximumApplicationAddress: 7FFEFFFF
dwActiveProcessorMask: 65535
dwNumberOfProcessors: 16
dwProcessorType: 586
dwAllocationGranularity: 65536
wProcessorLevel: 23
wProcessorRevision: 2050

NtQuerySystemInformation:
TimerResolution: 156250
PageSize: 4096
NumberOfPhysicalPages: 4182490
LowestPhysicalPageNumber: 1
HighestPhysicalPageNumber: 4322175
AllocationGranularity: 65536
MinimumUserModeAddress: 65536
MaximumUserModeAddress: 2147418111
ActiveProcessorsAffinityMask: 65535
NumberOfProcessors: 16
TimerResolution: 156250
TimerResolution: 156250
OneBlue commented 3 years ago

@petrroll : We have a theory on what could cause this issue: this could be due to memory fragmentation.

To validate that, can you please do the following:

petrroll commented 3 years ago

I'm currently on hiking vacation. Will test it on Wednesday soonest.

petrroll commented 3 years ago

Apologies, got busy with life. Will take a look at it this week hopefully.

petrroll commented 3 years ago

Just noticed I'd need to disable BitLocker and a few other things for that, I'm afraid I can't do that right now. Hopefully someone else might be able to help.

avinash311 commented 3 years ago

Same problem here, albeit on a very underpowered system - slow CPU and only 4GB RAM.

OS Name Microsoft Windows 10 Pro Education Version 10.0.19041 Build 19041 Processor AMD A6-9220C RADEON R5, 5 COMPUTE CORES 2C+3G, 1800 Mhz, 2 Core(s), 2 Logical Processor(s) Installed Physical Memory (RAM) 4.00 GB Total Virtual Memory 8.83 GB Available Virtual Memory 3.22 GB Page File Space 5.37 GB

lechenbauer-felix commented 3 years ago

Same problem on Windows 10 Enterprise Version 1903, Build 18362.1082 with Intel Xeon E-2174G (4*3.8GHz) + 16GB RAM

geelen commented 3 years ago

Just hit this, the second Terminal window I opened after turning my machine on today. Also \\wsl$\ paths weren't available.

Turned off Fast Startup and rebooted and it's worked again. On a Ryzen 5 2600, 16GB ram.

OneBlue commented 3 years ago

Given that @petrroll can't run dtrace, could someone else take a trace and follow the instructions I posted earlier to run dtrace ?

To validate that, can you please do the following:

- [Install and configure dtrace](https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/dtrace#installing-dtrace-under-windows)
- Reboot
- Download and extract [HvDeposit.zip](https://github.com/microsoft/WSL/files/5248338/HvDeposit.zip)
- Run "C:\Program Files\DTrace\dtrace.exe" -s HvDeposit.d
- Reproduce the issue
- Stop dtrace with ctrl-c
- Share the console output
mati865 commented 3 years ago
  • Reproduce the issue

It's the hard part. I haven't encountered it whole past month and today after few hours of normal PC usage it happened.

JelleFirlefyn commented 3 years ago

Disabling my McAfee fixed this problem for me.

avinash311 commented 3 years ago

Don't see it that often anymore, did see it once but could not run dtrace and after that wsl also ran correctly anyway.

Dtrace failed for HvDeposit.d (WIndows 10 Pro for Education):

dtrace.exe -s HvDeposit.d dtrace: failed to compile script HvDeposit.d: line 1: probe description fbt:vid:VidHvMemLowMemPolicyCallback:entry does not match any probes

My system is definitely very underpowered so maybe WSL won't work well - but would be good to confirm memory requirements: OS Name Microsoft Windows 10 Pro Education Version 10.0.19041 Build 19041 Processor AMD A6-9220C RADEON R5, 5 COMPUTE CORES 2C+3G, 1800 Mhz, 2 Core(s), 2 Logical Processor(s) Installed Physical Memory (RAM) 4.00 GB Total Virtual Memory 8.83 GB Available Virtual Memory 3.22 GB Page File Space 5.37 GB

I think dtrace itself is installed correctly - I see syscall as well as etw entries:

C:>dtrace.exe -l ID PROVIDER MODULE FUNCTION NAME 1 dtrace BEGIN 2 dtrace END 3 dtrace ERROR 4 syscall NtLockProductActivationKeys entry 5 syscall NtLockProductActivationKeys return ... 942 syscall NtSaveMergedKeys entry 943 syscall NtSaveMergedKeys return 944 etw b99cdb5a-039c-5046-e672-1a0de0a40211 0xff_0xffffffffffffffff generic_event 945 etw fbbd52e1-df97-529d-4b67-53f67da99a98 0xff_0xffffffffffffffff generic_event

globalistas commented 3 years ago

This started happening 2 days ago on my Ryzen 3700.

pieterdd commented 3 years ago

I have the same issue, also on a Ryzen CPU.

wooster0 commented 3 years ago

Same here. Maybe it's Ryzen-related?

mati865 commented 3 years ago

Same here. Maybe it's Ryzen-related?

If people didn't spam this thread with useless messages you could see the message saying it's related to high core count: https://github.com/microsoft/WSL/issues/5231#issuecomment-693104998