Registry Mirror
Skip to content

Loading issue when RID is linux-musl-x64 on Alpine 3.15 #65152

Closed

Description

@adityapatwardhan

Description

When loading dependencies of PowerShell on Alpine 3.15, it falls back to load linux-x64 dependencies. The issue does not repro with alpine 3.14. In both cases, the SDK version is 6.0.0.

It was found that the RID for Alpine 3.15 is missing on .NET 6 SDK. See: #62938

Note, dotnet --info does show the correct RID:

~/.dotnet/tools # dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     alpine
 OS Version:  3.15
 OS Platform: Linux
 RID:         linux-musl-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

I have attached load trace logs for the powershell load failure. loadtrace.txt

Excerpt below:

HostRID is alpine.3.15-x64
Falling back to base HostRID: linux-x64
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.linux
[loadtrace.txt](https://github.com/dotnet/runtime/files/8043912/loadtrace.txt)
-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.linux-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.PowerShell.Native/7.2.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.PowerShell.Native/7.2.0] may fail to load on this platform.
Chose linux-x64, so removing rid (win-x86) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (win-arm) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (win-x64) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (osx) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native

Reproduction Steps

On Alpine 3.15 container with .NET SDK

dotnet tool install --global PowerShell
~/.dotnet/tools/pwsh

Expected behavior

pwsh should execute correctly

Actual behavior

~/.dotnet/tools # ./pwsh
PowerShell 7.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

One or more errors occurred. (The type initializer for 'System.Management.Automation.TypeAccelerators' threw an exception.)
One or more errors occurred. (The type initializer for 'System.Management.Automation.TypeAccelerators' threw an exception.)
Cannot load PSReadline module. Console is running without PSReadline.
Process terminated. The type initializer for 'System.Management.Automation.PSObject' threw an exception.
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSObject' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK 6.0.0
Alpine 3.15

Other information

No response

Activity

  1. ghost added
    untriaged
    on Feb 10, 2022
  2. danmoseley commented on Feb 10, 2022

    @danmoseley
    Contributor

    It's a request for backport of #62938

    @wfurt we backport these, right?

  3. mthalman commented on Feb 10, 2022

    @mthalman
    Member

    It's not a matter of defining the Alpine RID. The Alpine RID shouldn't need to be defined for things to work correctly. It should be falling back to the linux-musl RID. The SDK represents correctly but the loader is falling back to linux, for some reason, not linux-musl.

  4. added
    area-AssemblyLoader-coreclr
    and removed on Feb 11, 2022
  5. vitek-karas commented on Feb 14, 2022

    @vitek-karas
    Member

    Backporting #62938 would fix this particular case, but I think @mthalman is also correct that the fallback logic in the host should handle MUSL based linuxes as special (it's too common not to).

    Basically we need to change this code here:

    // We cannot maintain the same (compat) invariant for linux and thus, we will fallback to using lowest RID-Plaform.
    #if defined(_WIN32)
    #define LIB_PREFIX
    #define MAKE_LIBNAME(NAME) (_X(NAME) _X(".dll"))
    #define FALLBACK_HOST_RID _X("win10")
    #elif defined(TARGET_OSX)
    #define LIB_PREFIX _X("lib")
    #define MAKE_LIBNAME(NAME) (LIB_PREFIX _X(NAME) _X(".dylib"))
    #define FALLBACK_HOST_RID _X("osx.10.12")
    #else
    #define LIB_PREFIX _X("lib")
    #define MAKE_LIBNAME(NAME) (LIB_PREFIX _X(NAME) _X(".so"))
    #if defined(TARGET_FREEBSD)
    #define FALLBACK_HOST_RID _X("freebsd")
    #elif defined(TARGET_ILLUMOS)
    #define FALLBACK_HOST_RID _X("illumos")
    #elif defined(__sun)
    #define FALLBACK_HOST_RID _X("solaris")
    #else
    #define FALLBACK_HOST_RID _X("linux")
    #endif
    #endif

    It should have a branch for MUSL linux and return linux-musl in that case.

  6. ghost added
    in-pr
    on Feb 14, 2022
  7. ghost removed
    in-pr
    on Feb 16, 2022
  8. mthalman commented on Feb 18, 2022

    @mthalman
    Member

    @vitek-karas - Since this issue shows up in 6.0, can we get it backported to that version?

  9. vitek-karas commented on Feb 18, 2022

    @vitek-karas
    Member

    @agocke can you try to flow this through triage?

    That said, we shipped like this for a long time (probably ever since .NET 3.1) - so it's likely not that important.

  10. agocke commented on Feb 18, 2022

    @agocke
    Member

    Sure, let’s give it a shot

  11. removed
    untriaged
    on Feb 18, 2022
  12. mthalman commented on Feb 18, 2022

    @mthalman
    Member

    That said, we shipped like this for a long time (probably ever since .NET 3.1) - so it's likely not that important.

    It seems to have revealed itself more so now, for some reason, with PowerShell. This was the original issue that identified this: PowerShell/PowerShell#16532. The issue showed up for .NET 6 but not for .NET 5 even though neither of them had the Alpine RID.

  13. vitek-karas commented on Feb 18, 2022

    @vitek-karas
    Member

    Thanks @mthalman - that sounds like a strong enough argument to me to take it. Let's see...

  14. ghost locked as resolved and limited conversation to collaborators on Mar 21, 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

    Labels

    area-AssemblyLoader-coreclr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions