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

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

Closed
adityapatwardhan opened this issue Feb 10, 2022 · 11 comments · Fixed by #65339
Closed

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

adityapatwardhan opened this issue Feb 10, 2022 · 11 comments · Fixed by #65339

Comments

@adityapatwardhan
Copy link

adityapatwardhan commented Feb 10, 2022

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

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 10, 2022
@ghost
Copy link

ghost commented Feb 10, 2022

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

Issue Details

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

Author: adityapatwardhan
Assignees: -
Labels:

area-Meta, untriaged

Milestone: -

@danmoseley
Copy link
Member

It's a request for backport of #62938

@wfurt we backport these, right?

@mthalman
Copy link
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.

@ghost
Copy link

ghost commented Feb 11, 2022

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

Issue Details

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

Author: adityapatwardhan
Assignees: -
Labels:

area-AssemblyLoader-coreclr, untriaged

Milestone: -

@vitek-karas
Copy link
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.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 14, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 16, 2022
@mthalman
Copy link
Member

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

@vitek-karas
Copy link
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.

@agocke
Copy link
Member

agocke commented Feb 18, 2022

Sure, let’s give it a shot

@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Feb 18, 2022
@mthalman
Copy link
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.

@vitek-karas
Copy link
Member

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

@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants