Skip to content

.NET 7 console executable fails with 'Failed to create CoreCLR, HRESULT: 0x8007000E' on Debian Linux (Seedbox) #79612

Closed

Description

@rcdailey

Description

A user of my application reports the following error:

Failed to create CoreCLR, HRESULT: 0x8007000E

Their environment is Debian Linux. My application is compiled as follows (taken from a powershell script of mine):

dotnet publish src/Recyclarr `
    --output publish `
    --configuration Release `
    --runtime linux-x64 `
    --self-contained=true `
    -p:PublishSingleFile=true `
    -p:IncludeNativeLibrariesForSelfExtract=true `
    -p:PublishReadyToRunComposite=true `
    -p:PublishReadyToRunShowWarnings=true `
    -p:EnableCompressionInSingleFile=true

I had them enable diagnostics and was sent the below log file.

trace.txt

Reproduction Steps

Run the application

Expected behavior

No CoreCLR exception

Actual behavior

Failed to create CoreCLR, HRESULT: 0x8007000E

Regression?

No response

Known Workarounds

No response

Configuration

Most of this is in the description above. I'm working on getting CPU architecture.

Other information

Original bug report is here:

recyclarr/recyclarr#152

Activity

  1. ghost added
    untriaged
    on Dec 13, 2022
  2. janvorli commented on Dec 13, 2022

    @janvorli
    Member

    @rcdailey this error code means "out of memory", so the diagnostics log you've shared doesn't help. The "out of memory" also really means "out of resources", so it could be out of file descriptor limit. Although it is unlikely to happen at coreclr initialization time.

    strace log should show the source of the issue. You can capture it using
    strace -o stracelog.txt -f /path/to/your/app. The -f means "follow children".

    strace logs syscalls and their return values, so if e.g. mmap fails, or open fails, it would show up.

    Also, I have just added logging of extended information on coreclr initialization failures in the current main. If you could provide your user a version of your app built against main (using SDK from https://github.com/dotnet/installer), that also might shed a light on where the OOM came from.

  3. rcdailey commented on Dec 14, 2022

    @rcdailey
    Author

    The user says they aren't allowed to run strace. I don't know why. They said it's a "shared" environment, but I don't know exactly what that means. I assume that has something to do with why he cants run it?

    Are there other diagnostic commands that can be run?

    Thanks for your help.

  4. janvorli commented on Dec 14, 2022

    @janvorli
    Member

    It would be interesting to know how much memory the environment has and few other details like this. Here are some commands to get it:

    cat /proc/meminfo
    ulimit -a

    I also wonder - is the user running it in some sort of container that could limit the memory for the process (like docker, etc)?

  5. rcdailey commented on Dec 14, 2022

    @rcdailey
    Author

    @janvorli Here are the outputs of those commands:

    As for the second question i dont think so. I think its more of different VM's on a machine shared across users.

    Thanks for your continued support!

  6. janvorli commented on Dec 15, 2022

    @janvorli
    Member

    I think I can see the problem. The ulimit for virtual memory is set to just 10GB. We expect virtual memory space to be unlimited (on 64 bit systems each process can use upto about 128TB of virtual address space if the limit is not set). GC reserves large virtual address range for the heap, which is almost for sure the reason for the out of memory failure. It is something that we would like to fix in the future, since there were already few cases where people have hit this limitation. See the discussion in the #7740 for more details.

    Your user can try to limit the amount of virtual memory used by the GC using the environment variable

    DOTNET_GCHeapHardLimit=1C0000000
    

    This would limit GC heap max size to 7GB.

    There are other ways to achieve similar thing, but this is the most straightforward for the current case.

  7. added
    question
    on Dec 15, 2022
  8. rcdailey commented on Dec 15, 2022

    @rcdailey
    Author

    @janvorli Thanks once again for hopping over to the source issue to help. Greatly appreciated.

    Now that the user has a workaround, what's the conclusion here? It seems like this was an environment-specific issue on their side and there is no change needed here.

    At the very least I've learned some good diagnostic commands to run next time this happens. Feel free to close out this issue if you feel nothing else is needed.

  9. janvorli commented on Dec 15, 2022

    @janvorli
    Member

    @rcdailey I am going to add detection of a set virtual memory limit to our runtime so that in future, the workaround of limiting the GC heap size would not be needed. We've discussed that in the past already, but as the case when there is a virtual memory limit set is a very rare case, it didn't make it high enough in the priority list of work.
    But since it surfaced again now, I am going to prioritize it.

  10. am11 commented on Feb 21, 2023

    @am11
    Member

    @janvorli, would it make sense to include some stats (fromGlobalMemoryStatusEx() etc.) in this error message?

    I was trying to figure out why a simple hello world refuses to run without procfs although we have fallbacks in place.

    Here is an experiment with installer daily build 8.0.100-preview.2.23117.18 (includes exe path fix)
    # host machine: osx-arm64: publish for linux-arm
    
    # create and publish net8.0 linux-arm app
    $ dotnet new console -n exe1
    $ dotnet publish exe1 -p:InvariantGlobalization=true --self-contained -r linux-arm64 -o dist
    
    # interactively run a privileged container so we can later unmount procfs 
    $ docker run -v$(pwd)/dist:/app --privileged -it ubuntu
    
    # run the app 
    $ /app/exe1
    Hello, World!
    
    # un-mount procfs and try again
    $ umount /proc
    $ /app/exe1
    Failed to create CoreCLR, HRESULT: 0x8007000E
    
    # diagnose ...
    $ sh -c 'apt update && apt install -y strace curl' &>/dev/null
    $ strace -f /app/exe1 2>&1 | curl -F"sprunge=<-" http://sprunge.us
    http://sprunge.us/VE1Gcg
    
    $ getconf -a | grep -i page
    PAGESIZE                           4096
    PAGE_SIZE                          4096
    _AVPHYS_PAGES                      1636833
    _PHYS_PAGES                        3770763
    
    # so it should be limited to {PAGE * _AVPHYS_PAGES} to match PAL and GC?
    $ printf '%X\n' $(($(getconf PAGESIZE) * $(getconf _AVPHYS_PAGES)))
    18FD5E000
    
    $ DOTNET_GCHeapHardLimit=18FD5E000 /app/exe1
    Failed to create CoreCLR, HRESULT: 0x8007000E
    
    # try with some small limit
    $ DOTNET_GCHeapHardLimit=12345678 /app/exe1
    Failed to create CoreCLR, HRESULT: 0x8007000E
    
    # remount /proc to go back to working state
    $ mount -t proc proc /proc

    FWIW, nativeaot published apps work fine without procfs; when it's completely absent or when it's inaccessible (in constrained environment).

  11. mangod9 commented on Jul 24, 2023

    @mangod9
    Member

    Closing since the original question is resolved.

  12. ghost removed
    untriaged
    on Jul 24, 2023
  13. ghost locked as resolved and limited conversation to collaborators on Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VM-coreclrquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions