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

MachOUtils.cs is not endian-independent. #74163

Open
jkoritzinsky opened this issue Aug 18, 2022 · 3 comments
Open

MachOUtils.cs is not endian-independent. #74163

jkoritzinsky opened this issue Aug 18, 2022 · 3 comments
Labels
area-HostModel Microsoft.NET.HostModel issues
Milestone

Comments

@jkoritzinsky
Copy link
Member

From #72394:

The problem seems to be that the new mono.tools subset now builds dotnet-pgo.csproj, which tries to create an osx-x64 shim apphost:

    <PackAsToolShimRuntimeIdentifiers>win-x64;win-x86;win-arm;osx-x64</PackAsToolShimRuntimeIdentifiers>

This in turn pulls in code in src/installer/managed/Microsoft.NET.HostModel/AppHost/MachOUtils.cs to manipulate MachO binaries, but that whole file unfortunately fundamentally seems to assume little-endian byte order, as it just mmaps the binary and then overlays structures over the mmap.

So the question is, what is the best way to fix this? Of course, we could try to rewrite MachOUtils.cs to be endian-independent. But I'm wondering if we even need to build this on s390x? Do you think it would make sense to skip building dotnet-pgo completely (or at least building the osx-x64 shim), either whenever PrimaryRuntimeFlavor is Mono or specificially just on s390x due to the endian issue?

Are the tools in dotnet-pgo even useful at all on a system where we're not supporting CoreCLR at all?

Originally posted by @uweigand in #72394 (comment)

@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.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 18, 2022
@jkoritzinsky jkoritzinsky added area-HostModel Microsoft.NET.HostModel issues and removed untriaged New issue has not been triaged by the area owner labels Aug 18, 2022
@jkoritzinsky jkoritzinsky added this to the Future milestone Aug 18, 2022
@ghost
Copy link

ghost commented Aug 18, 2022

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

Issue Details

From #72394:

The problem seems to be that the new mono.tools subset now builds dotnet-pgo.csproj, which tries to create an osx-x64 shim apphost:

    <PackAsToolShimRuntimeIdentifiers>win-x64;win-x86;win-arm;osx-x64</PackAsToolShimRuntimeIdentifiers>

This in turn pulls in code in src/installer/managed/Microsoft.NET.HostModel/AppHost/MachOUtils.cs to manipulate MachO binaries, but that whole file unfortunately fundamentally seems to assume little-endian byte order, as it just mmaps the binary and then overlays structures over the mmap.

So the question is, what is the best way to fix this? Of course, we could try to rewrite MachOUtils.cs to be endian-independent. But I'm wondering if we even need to build this on s390x? Do you think it would make sense to skip building dotnet-pgo completely (or at least building the osx-x64 shim), either whenever PrimaryRuntimeFlavor is Mono or specificially just on s390x due to the endian issue?

Are the tools in dotnet-pgo even useful at all on a system where we're not supporting CoreCLR at all?

Originally posted by @uweigand in #72394 (comment)

Author: jkoritzinsky
Assignees: -
Labels:

area-HostModel

Milestone: -

@jkoritzinsky
Copy link
Member Author

Extracting this comment out to a separate issue so if we hit it again, we can reference this (and consider fixing).

The existing case was mitigated by skipping building dotnet-pgo.csproj on S390X: #74147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-HostModel Microsoft.NET.HostModel issues
Projects
None yet
Development

No branches or pull requests

1 participant