-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Incorrect OS architecture reported for x86 code running on ARM64 #26612
Comments
Note that (at least) starting with Windows 10 (ARM64) Build 21277, when running an x86 process, I'm in favor of fixing the implementation of the .NET properties (in a new major release), so that I think the behavior of For example, an app might want to detect if it runs as x86/x64 on an ARM64 OS, to notify the user that for better performance the native ARM64 version should be used. Currently, we have to p/invoke
I think the documentation doesn't correctly reflect the version where this function is available; Thanks! |
It seems that |
|
Should we consider doing this in 6.0.0 since we're making a push to get x64 on ARM64 working better? @richlander what are your thoughts? Seems like we can have RuntimeInformation check for https://docs.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2 and use it if available, otherwise fallback to using GetNativeSystemInfo. Alternatively we follow Windows' lead and create a new API that exposes this info. I don't think it's correct to not expose this, it's basically the same problem that the existing API was trying to solve. |
@ericstj I have included you on the email thread where we have discussed it. It is unclear whether fixing this would be an improvement. It is likely to break some applications that depend on this API. OSArchitecture is a questionable API that is unlikely to be ever 100% right. For example, the API won’t return the actual OS architecture under Linux QEMU either. The primary goal of the OS architecture emulation is to hide the actual OS architecture, and make everything look like emulated architecture. The implementation of the OSArchitecture API has to defeat that, so this API is basically in arms race with how good the OS architecture emulation is. |
+1 -- we talked to the Windows folks and decided to leave our implementation as-is. I started from the viewpoint that we should change it. I did not realize that WoW64 has always had this behavior. x84 on Arm64 is the same as that, so changing it doesn't seem very compelling. |
Closing per the discussion above that the current behavior is the better option. |
When x86 code is executed on an ARM64 Windows,
System.Runtime.InteropServices.RuntimeInformation.OSArchitecture
returnsX86
andSystem.Environment.Is64BitOperatingSystem
returnsFalse
. These two properties callGetNativeSystemInfo
andIsWow64Process
Kernel32.dll functions respectively, which conceal the real OS architecture from x86 code by returningPROCESSOR_ARCHITECTURE_INTEL
(meaning x86) andFALSE
. To obtain the real OS architecture, Windows 10 introduced a newIsWow64Process2
function in version 1511.We need to make a decision how an app may reliably figure out the real OS architecture it is running on:
Should we fix the implementation of the existing CoreFX properties?
Or do we recommend resorting to an
IsWow64Process2
PInvoke wrapped in a necessarytry
/catch
?The text was updated successfully, but these errors were encountered: