Skip to content

Conversation

adityamandaleeka
Copy link
Member

Fixes #63650

A recent change (#61894) inadvertently regressed a scenario that was working by accident.

That change switched us away from using GetBinaryTypeW to determine the architecture of a binary, because that method actually loads the binary into the process and we wanted to avoid that. However, what was missed there is that in some cases (e.g. x64 process running on arm64) the function fails entirely (since it can't even load the binary), which used to lead us to skip that binary when doing our probing and instead rely on fallback methods.

After #61894, we started to correctly determine that both x64 and arm64 binaries are 64-bit, but since we weren't distinguishing between the two, we could end up attempting to load the wrong one.

This fixes that by actually determining the specific architecture and ensuring a match. There's some nearby code that needs to be rethought as well, but I'm trying to keep this change minimal so we can minimize risk late in .NET 10.


if (fIsCurrentProcess64Bit == IsX64(struDotnetSubstring.QueryStr()))
ProcessorArchitecture dotnetArch = GetFileProcessorArchitecture(struDotnetSubstring.QueryStr());
if (dotnetArch == currentProcessArch)
Copy link
Member

@DeagleGross DeagleGross Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if both currentProcessArch and dotnetArch equal ProcessorArchitecture::Unknown? I cant determine the behavior in such a case - maybe we should check it and at least log in such scenario?

        if (dotnetArch == currentProcessArch)
		{
			if (dotnetArch == ProcessorArchitecture::Unknown)
			{
				LOG_INFOF(L"dotnet.exe and current process architectures are unknown. Behavior can be unexpected");
			}
		    // continue 
		}	

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetCurrentProcessArchitecture will never be unknown. If we don't know it at build time there's a static assert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IIS running on arm64 with x64 emulation loading incorrect hostfxr?
2 participants