-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[ARM32/Windows] Invalid access to memory location #27943
Comments
You can reproduce this behavior with the following simple app as well.
|
This looks like a bug with respecting memory alignment. The code is casting pinned cc @JeremyKuhne |
@jkotas interesting, how should we be handling this sort of thing? Presumably this isn't the first time we've had to deal with something like this? |
Use regular malloc/free ( Alternatively, you can align up the pinned |
Thanks @jkotas! That's excellent insight. Is this only a problem on 32-bit ARM. What about 64-bit? Do we have a servicing branch for 2.2 yet? |
Correct, this is a problem for Windows 32-bit ARM only. Windows 64-bit ARM should be fine (we are lucky).
We do not have special servicing branches. Servicing is done by submitting PRs against release branches (https://github.com/dotnet/corefx/tree/release/2.2). Servicing shiproom merges the fixes when appropriate. |
On the servicing branch ... what I really meant "are we still using 2.2 for RTM or can we merge PRs to it yet (with appropriate approval)?" |
That's a question for shiproom to answer on case by case basis. We have not released 2.2 RTM yet, so we have an option to rebuild it with more fixes if warranted. I doubt that shiproom would take this particular fix for 2.2 RTM: The runway is short, the fix is not going to be trivial one-liner and it will affect all platforms, not just Windows ARM. |
All of that makes sense to me and aligns with my expectations, too. |
@jkotas Why is the alignment of .NET allocated arrays different on ARM32? Why doesn't it match x86? Am I missing something else about why this works on x86? |
The alignment of .NET allocated arrays is exactly same between x86 and ARM32. The binary unmanaged ABI is different between X86 and ARM32: The required alignment for |
This bug is blocking us supporting Windows ARM32 for .NET Core 2.2. Can you ensure that a fix gets into .NET Core 2.2.1? |
Yep, on it. |
@JeremyKuhne let me know when you have the PR ready. |
Tagging just so I don't lose it. We have a few days still before 2.2.1 code complete. |
@jkotas would this affect other structs we use that have long fields? eg TransmitPacketsElement, TOKEN_STATISTICS, SECURITY_LOGON_SESSION_DATA .. I see several. Can the runtime help flag this? It knows the sizes. |
This is only a problem if you are writing unsafe code that casts byte pointer to the pointer to the struct. If you leave it up to the runtime to allocate the struct (on stack or on heap), it is going to have the right alignment. As far as I can tell, all the cases you have listed are allocated by the runtime and do not have this problem. |
Just hit this trying to run a self-hosted ASP.NET Core site as part of a BackgroundTask on IoT Core. That is, it's actually UWP => .NET Standard 2.0 library with app startup info => ASP.NET Core 2.0 The build and deploy seems to work, but I get the error noted here when ASP.NET Data Protection tries to save info to the filesystem. I'm hoping maybe someone can point me to some docs or other resources that might explain...
I've tried searching but getting the right terms to get decent results is hard. "Core" could be .NET Core, IoT Core, ASP.NET Core... 🤔 |
@jkotas I thought Windows arm32 fixed up all unaligned accesses (except interlocked). Is that not true for the OSes listed in this issue (Windows IOTCore and Windows Nano Server, in containers)? |
And floating point access.
The Windows OS APIs expect struct pointers to be aligned properly. They check their alignment upfront when it may cause problems (e.g. I know that there are or at least used to be APIs that take CONTEXT structure and that failed on x86/x64 when the CONTEXT structure was not aligned properly). You can argue about whether the check for this particular API is really required, and whether it would be better to just relax the check for this particular in Windows to workaround this. Even if the check in this particular API is relaxed after auditing the implementation, there will be others where it is not going to be the case. The short answer is: It is best to make the alignment right if you want your code to be portable. |
Could you please let me know when this is released? I am at a cross-roads on this same error, but I am running on a RPi3. The app is running on a removable USB thumb drive, and it is accessing other removable USB thumb drives. The exception is intermittent, and usually multiple request (1-20 times) will force it to read eventually. I found that re-instantiating the DirectoryInfo class helps. My next step is to try to return the paths, and the use a DirectroyInfo for each path. |
Fixed in 3.0 in PR dotnet/corefx#33713. |
We use UWP apps for Arm32 on raspberry 3 and got into this issue with nuget package Microsoft.NETCore.UniversalWindowsPlatform version 6.2.8.
|
Since 6.2.9 is now released I retried it and got still an issue:
|
@trivalik .NET Native for UWP (ie what you are using) is a different product from .NET Core. This bug was not patched for .NET Native for UWP. If you would like to see it patched for .NET Native, the best way to do that is to email [email protected] or report the problem via https://developercommunity.visualstudio.com/ . cc @tommcdon |
Results:
If you run
dotnet run
you get the same exception just a little different code path..NET Core SDK (reflecting any global.json):
Version: 2.2.100
Commit: 51868761f2
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-arm
Base Path: C:\Program Files\dotnet\sdk\2.2.100\
Host (useful for support):
Version: 2.2.0
Commit: 1249f08fed
.NET Core SDKs installed:
2.2.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The text was updated successfully, but these errors were encountered: