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

Failed to initialize CoreCLR, HRESULT: 0x8007000E when LimitNPROC=10 set via systemd unit #109442

Open
perlun opened this issue Nov 1, 2024 · 5 comments
Labels
area-VM-coreclr untriaged New issue has not been triaged by the area owner

Comments

@perlun
Copy link
Contributor

perlun commented Nov 1, 2024

Description

When LimitNPROC=10 is set in a systemd unit for a .NET 8 application, the process exits with a Failed to create CoreCLR, HRESULT: 0x8007000E error.

Reproduction Steps

Set up a systemd unit like this:

[Unit]
Description=Some .NET Program
After=network-online.target
Wants=network-online.target
 
[Service]
Type=simple
User=someuser
PrivateTmp=true
WorkingDirectory=/path/to/dotnet-program
ExecStart=/path/to/dotnet-program/some-program
LimitNPROC=10
ProtectSystem=true
ProtectHome=true
KillMode=process
 
[Install]
WantedBy=multi-user.target

The .NET runtime fails to start, because of the error described above.

Expected behavior

Successful startup of the application.

Actual behavior

The process exits with a Failed to create CoreCLR, HRESULT: 0x8007000E error.

Regression?

No response

Known Workarounds

Remove the LimitNPROC line, or set LimitNPROC=infinity. This makes the problem immediately go away.

Configuration

  • Standalone .NET application published using dotnet publish --self-contained true -c Release -r linux-x64 -f net8.0 path/to/project.csproj
  • .NET SDK 8.0.401 used in container where the app is published
  • Target host: Ubuntu 24.04.1 LTS (x86-64)

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 1, 2024
Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@perlun
Copy link
Contributor Author

perlun commented Nov 1, 2024

Remove the LimitNPROC line, or set LimitNPROC=infinity. This makes the problem immediately go away.

Also worth pointing out: The User=someuser part is critical to be able to reproduce this. This is by design. Quoting from: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#LimitCPU=

Please also note that the LimitNPROC= will not be enforced if the service is running as root (and not dropping privileges).

@janvorli
Copy link
Member

janvorli commented Nov 5, 2024

I think it may be because of the nproc limit actually limiting the number of threads, not only processes. If you run with server GC, there is by default one extra thread per CPU for GC purposes. That can easily go over the 10 you are setting it to.

@perlun
Copy link
Contributor Author

perlun commented Nov 12, 2024

That can easily go over the 10 you are setting it to.

Interesting @janvorli. 🤔 The machine where we saw this is an Azure VM with 2 vCPUs for reference.

How do you control whether server GC is used or not, is it auto-determined by the runtime somehow?

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

3 participants