Repository navigation
Closed
Labels
arch-s390xRelated to s390x architecture (unsupported)
Milestone
Description
Using a .NET 8 RC 1 SDK compiled on s390x with #90292 applied locally, dotnet tool install -g dotnet-ef fails:
$ dotnet tool install -g dotnet-ef
Unhandled exception: Microsoft.NET.HostModel.AppHost.AppHostNotPEFileException: Selected apphost is not a valid PE file. Subsystem offset out of file range.
at Microsoft.NET.HostModel.AppHost.PEUtils.GetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor)
at Microsoft.NET.HostModel.AppHost.PEUtils.GetWindowsGraphicalUserInterfaceBit(String filePath)
at Microsoft.DotNet.ShellShim.AppHostShellShimMaker.CreateApphostShellShim(FilePath entryPoint, FilePath shimPath)
at Microsoft.DotNet.ShellShim.ShellShimRepository.<>c__DisplayClass5_0.<CreateShim>b__0()
at Microsoft.DotNet.Cli.TransactionalAction.<>c__DisplayClass5_0.<Run>b__0()
at Microsoft.DotNet.Cli.TransactionalAction.Run[Object](Func`1 action, Action commit, Action rollback)
at Microsoft.DotNet.Cli.TransactionalAction.Run(Action action, Action commit, Action rollback)
at Microsoft.DotNet.ShellShim.ShellShimRepository.CreateShim(FilePath targetExecutablePath, ToolCommandName commandName, IReadOnlyList`1 packagedShims)
at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
at Microsoft.DotNet.Tools.Tool.Install.ToolInstallCommand.Execute()
at Microsoft.DotNet.Cli.ToolInstallCommandParser.<>c.<ConstructCommand>b__17_0(ParseResult parseResult)
at System.CommandLine.Invocation.AnonymousCliAction.Invoke(ParseResult parseResult)
at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
at System.CommandLine.ParseResult.Invoke()
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
The stack trace suggests this is the culprit:
runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs
Lines 114 to 142 in 32c3355
| internal static unsafe ushort GetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor) | |
| { | |
| byte* pointer = null; | |
| try | |
| { | |
| accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer); | |
| byte* bytes = pointer + accessor.PointerOffset; | |
| // https://en.wikipedia.org/wiki/Portable_Executable | |
| uint peHeaderOffset = ((uint*)(bytes + PEOffsets.DosStub.PESignatureOffset))[0]; | |
| if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) | |
| { | |
| throw new AppHostNotPEFileException("Subsystem offset out of file range."); | |
| } | |
| ushort* subsystem = ((ushort*)(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem)); | |
| return subsystem[0]; | |
| } | |
| finally | |
| { | |
| if (pointer != null) | |
| { | |
| accessor.SafeMemoryMappedViewHandle.ReleasePointer(); | |
| } | |
| } | |
| } |
Probably an endianness issue?
Metadata
Metadata
Assignees
Labels
arch-s390xRelated to s390x architecture (unsupported)
Type
Projects
- StatusShow more project fieldsNo status
Activity
omajid commentedon Sep 20, 2023
cc @uweigand @Vishwanatha-HD
[-]Selected apphsot is not a valid PE file on s390x[/-][+]Selected apphost is not a valid PE file on s390x[/+]agocke commentedon Sep 20, 2023
Cc @elinor-fung . Looks like endianness mismatch in the new resource writing code.
elinor-fung commentedon Sep 20, 2023
Taking a look. It's just in
GetWindowsGraphicalUserInterfaceBit, not at the point of trying to write resources yet - I don't think that was changed (constants were just moved to a shared place).agocke commentedon Sep 20, 2023
Yeah, that
uint*cast looks pretty suspicious -- that'll be reversed on big-endian.elinor-fung commentedon Sep 20, 2023
Oh, I think this is because
AppHostShimMakerhad an implicit assumption thatResourceUpdater.IsSupportedOS()is tied to Windows.https://github.com/dotnet/sdk/blob/d4f2153fdbdbd5ee6b793c03fc908254fa6b253c/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs#L44-L47
Before,
GetWindowsGraphicalUserInterfaceBitwas never getting called on non-Windows, but now,ResourceUpdater.IsSupportedOS()is also true on non-Windows.omajid commentedon Sep 27, 2023
Shall I close this issue now that all the linked PRs have been merged?