You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.Net application aborts at startup with "Failed to create CoreCLR, HRESULT: 0x80004005" - .Net 7 preview 5 #70758
The app compiles and runs fine on my M1 Macbook (I'm using VS for Mac 2022). However, when built and deployed to a docker container, and launched on Linux (I'm using a Synology NAS) it fails with:
Failed to create CoreCLR, HRESULT: 0x80004005
The same app launched fine built and ran (on both OSX and Linux) against .Net 7 preview 4.
I'll do some additional tests tomorrow to see if I can narrow down to the specific update that cause this to break (i.e., is it .Net 7 preview 5 itself, or some other dep, or a combination of the two). The app is a Blazor Server app running as a self-contained single-file executable, but since it never gets as far as initialising the CLR I don't think that Blazor or ASP.Net is relevant. I've also tried disabling trimming, but it didn't resolve the issue.
I guess my first question is - how do I go about getting additional debugging information to figure out what's causing this problem?
Reproduction Steps
Take my app, build and run it against .Net 7 preview 4. It works. Upgrade to preview 5, it fails to start.
Expected behavior
App runs successfully on both OSX and Linux.
Actual behavior
App runs successfully on OSX, but on Linux the app fails to start with Failed to create CoreCLR, HRESULT: 0x80004005
Unfortunately COREHOST_TRACE doesn't tend to work well with EFAIL (that's what 0x80004005 is). That means something has gone wrong during runtime startup. @vitek-karas might have some ideas, and + @VSadov for potential single-file issues.
Just on the off-chance it yields any clues, here's the COREHOST_TRACE output for the process (had to rename to .txt, but if you rename to .html it'll render as a table of log entries, newest-first).
Presumably the easy fix for this is for you to check the linux kernel version at startup and set COMPlus_EnableWriteXorExecute=0 if it's older than 3.17?
memfd_create("doublemapper", MFD_CLOEXEC) = -1 ENOSYS (Function not implemented)
You are right, we can either disable the W^X when this syscall isn't implemented or possibly fall back to using shm_open. Given the fact that the 3.17 was released in 2015, I tend to the first option.
Sounds good. Happy for you to close this issue (presuming you'll spin off a dev ticket for preview 6/7 to fix as above). I've updated my build to set the env var which will workaround the problem until then.
The runtime introspection approach is better than version check. CentOS 7 (aka pretty important distro) has kernel version 3.10.0-1160.el7.x86_64 and it doesn't fail 9858 memfd_create("doublemapper", MFD_CLOEXEC) = 8.
COMPlus__
minor nit: the way runtime config lookup works is for a desired config XYZ, it first looks for DOTNET_XYZ then fallback to "legacy" COMPlus_XYZ. So here, you can simply use DOTNET_EnableWriteXorExecute to avoid an extra probe.
BTW, some additional info, in case it's of interest. My friend who tested the binary on his WIndows WSL setup (and was able to repro the CoreCLR failure there) got me the kernel version:
ngm@GAMER:~$ uname -r
4.4.0-19041-Microsoft
So I'm guessing that MSFT's Win10 WSL Kernel isn't versioned consistently or is built in a different way.
Activity
AaronRobinsonMSFT commentedon Jun 15, 2022
@Webreaper You might start with setting the environment variable
COREHOST_TRACE=1. Details on this can be found at https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/default-probing#how-do-i-debug-the-probing-properties-construction and https://github.com/dotnet/runtime/blob/main/docs/design/features/host-tracing.md./cc @elinor-fung
agocke commentedon Jun 15, 2022
Unfortunately COREHOST_TRACE doesn't tend to work well with EFAIL (that's what 0x80004005 is). That means something has gone wrong during runtime startup. @vitek-karas might have some ideas, and + @VSadov for potential single-file issues.
Webreaper commentedon Jun 15, 2022
Okay, thanks. Any other logging I can turn on?
Just on the off-chance it yields any clues, here's the COREHOST_TRACE output for the process (had to rename to .txt, but if you rename to .html it'll render as a table of log entries, newest-first).
damselfly_log.txt
I'll continue fiddling with some build settings to see if I can find an explicit link to something.
am11 commentedon Jun 15, 2022
@Webreaper, does it still fail if you switch to daily build plan?
Webreaper commentedon Jun 15, 2022
Hey @am11, I just tried that, but it's failing to pull packages from Nuget in my Github build, e.g.:
Is there anything else I need to switch to allow me to pull that newer version (I've not used the dailies before)?
am11 commentedon Jun 15, 2022
Webreaper/Damselfly@3d3e7dd#r76136400
Webreaper commentedon Jun 15, 2022
Thanks, just saw that!
Webreaper commentedon Jun 15, 2022
Okay, thanks to @am11 's help, I got a build working using the daily build, but I still see the same CoreCLR failure.
24 remaining items
Webreaper commentedon Jun 15, 2022
Looks like that's it:
Webreaper commentedon Jun 15, 2022
Sounds like we've got to the bottom of it, but just in case it helps, here's that
stracelog from Damselfly.trace.log
Presumably the easy fix for this is for you to check the linux kernel version at startup and set
COMPlus_EnableWriteXorExecute=0if it's older than 3.17?Fix for dotnet/runtime#70758
janvorli commentedon Jun 15, 2022
Yes, the log confirms that:
You are right, we can either disable the W^X when this syscall isn't implemented or possibly fall back to using
shm_open. Given the fact that the 3.17 was released in 2015, I tend to the first option.Webreaper commentedon Jun 16, 2022
Sounds good. Happy for you to close this issue (presuming you'll spin off a dev ticket for preview 6/7 to fix as above). I've updated my build to set the env var which will workaround the problem until then.
Appreciate all the help, everyone!
am11 commentedon Jun 16, 2022
The runtime introspection approach is better than version check. CentOS 7 (aka pretty important distro) has kernel version
3.10.0-1160.el7.x86_64and it doesn't fail9858 memfd_create("doublemapper", MFD_CLOEXEC) = 8.minor nit: the way runtime config lookup works is for a desired config XYZ, it first looks for
DOTNET_XYZthen fallback to "legacy"COMPlus_XYZ. So here, you can simply useDOTNET_EnableWriteXorExecuteto avoid an extra probe.janvorli commentedon Jun 16, 2022
@Webreaper I'll keep this open to track it until the fix is in.
@am11 my plan is to base it on the failed
memfd_createrather than a version check.Webreaper commentedon Jun 16, 2022
BTW, some additional info, in case it's of interest. My friend who tested the binary on his WIndows WSL setup (and was able to repro the CoreCLR failure there) got me the kernel version:
So I'm guessing that MSFT's Win10 WSL Kernel isn't versioned consistently or is built in a different way.
janvorli commentedon Jun 16, 2022
Has he verified that it fails due to the same issue? This kernel version should support this syscall, so I'd think it is some other problem here.
am11 commentedon Jun 16, 2022
BTW
memfd_createwas not supported on WSL 1 microsoft/WSL#3542.Webreaper commentedon Jun 16, 2022
That explains it. He upgraded to WSL2 and it worked fine there.