Skip to content

.Net application aborts at startup with "Failed to create CoreCLR, HRESULT: 0x80004005" - .Net 7 preview 5 #70758

Closed

Description

@Webreaper

Description

I have a project here: https://github.com/Webreaper/Damselfly which I upgraded to .Net 7 preview 5 this evening, and also updated EF Core and a bunch of other dependencies (Webreaper/Damselfly@master...develop).

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

Regression?

Yes, this app worked with .Net 7 preview 4.

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. ghost added
    untriaged
    on Jun 14, 2022
  2. added this to the 7.0.0 milestone on Jun 15, 2022
  3. removed
    untriaged
    on Jun 15, 2022
  4. agocke commented on Jun 15, 2022

    @agocke
    Member

    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.

  5. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    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.

  6. am11 commented on Jun 15, 2022

    @am11
    Member

    @Webreaper, does it still fail if you switch to daily build plan?

    -         dotnet-version: '7.0.100-preview.5.22307.18'
    +         dotnet-version: '7.0.100-preview.6.22314.18'
  7. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    Hey @am11, I just tried that, but it's failing to pull packages from Nuget in my Github build, e.g.:

    /home/runner/work/Damselfly/Damselfly/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Runtime.linux-x64 with version (= 7.0.0-preview.6.22312.1) [/home/runner/work/Damselfly/Damselfly/Damselfly.Web/Damselfly.Web.csproj]
    /home/runner/work/Damselfly/Damselfly/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj : error NU1[10](https://github.com/Webreaper/Damselfly/runs/6895291025?check_suite_focus=true#step:5:11)2:   - Found 89 version(s) in nuget.org [ Nearest version: 7.0.0-preview.5.22301.12 ] [/home/runner/work/Damselfly/Damselfly/Damselfly.Web/Damselfly.Web.csproj]
    

    Is there anything else I need to switch to allow me to pull that newer version (I've not used the dailies before)?

  8. am11 commented on Jun 15, 2022

    @am11
    Member
  9. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    Thanks, just saw that!

  10. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    Okay, thanks to @am11 's help, I got a build working using the daily build, but I still see the same CoreCLR failure.

  11. 24 remaining items

  12. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    Looks like that's it:

    admin@PoundNAS:~$ uname -r
    3.10.108
    
  13. Webreaper commented on Jun 15, 2022

    @Webreaper
    Author

    Sounds like we've got to the bottom of it, but just in case it helps, here's that strace log 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=0 if it's older than 3.17?

  14. added a commit that references this issue on Jun 15, 2022
  15. janvorli commented on Jun 15, 2022

    @janvorli
    Member

    Yes, the log confirms that:

    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.

  16. Webreaper commented on Jun 16, 2022

    @Webreaper
    Author

    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!

  17. am11 commented on Jun 16, 2022

    @am11
    Member

    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.

  18. janvorli commented on Jun 16, 2022

    @janvorli
    Member

    @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_create rather than a version check.

  19. Webreaper commented on Jun 16, 2022

    @Webreaper
    Author

    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.

  20. janvorli commented on Jun 16, 2022

    @janvorli
    Member

    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.

  21. am11 commented on Jun 16, 2022

    @am11
    Member

    BTW memfd_create was not supported on WSL 1 microsoft/WSL#3542.

  22. Webreaper commented on Jun 16, 2022

    @Webreaper
    Author

    That explains it. He upgraded to WSL2 and it worked fine there.

  23. ghost added
    in-pr
    on Jun 17, 2022
  24. ghost removed
    in-pr
    on Jun 20, 2022
  25. ghost locked as resolved and limited conversation to collaborators on Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions