Bug: memory access violation after cross-arch NAOT compilation
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 665
- Forks
- 134
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 32
Description
Description
I've created a carousel for my app, here are the codes:
- https://github.com/HotCakeX/Harden-Windows-Security/blob/6ebad34955525279145353a83b6a26c2596bf6a5/AppControl%20Manager/CustomUIElements/FeatureHighlightsCarouselDialog.xaml.cs
- https://github.com/HotCakeX/Harden-Windows-Security/blob/6ebad34955525279145353a83b6a26c2596bf6a5/AppControl%20Manager/CustomUIElements/FeatureHighlightsCarouselDialog.xaml
When I compile it on X64 hardware and run it on ARM64 hardware, my app crashes with this error in event logs
Application: HardenSystemSecurity.exe
CoreCLR Version: 10.0.11
Description: The application requested process termination through System.Environment.FailFast.
Message: Access Violation: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The application will be terminated since this platform does not support throwing an AccessViolationException.
Stack:
at System.RuntimeExceptionHelpers.FailFast(String, Exception, String, RhFailFastReason, IntPtr, IntPtr) + 0x39c
at System.RuntimeExceptionHelpers.GetRuntimeException(ExceptionIDs) + 0x190
at System.Runtime.EH.GetClasslibException(ExceptionIDs, IntPtr) + 0x74
at AppControlManager.CustomUIElements.FeatureHighlightsCarouselDialog.RotateSlides(Boolean) + 0x158
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr, IntPtr, IntPtr) + 0xa4
at ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(IObjectReference, ApplicationInitializationCallback) + 0x1b8
at HardenSystemSecurity.XamlGeneratedProgram.XamlGeneratedMain() + 0x2c0
at HardenSystemSecurity.Program.Main(String[] args) + 0x4f4
The way to fix it is by changing this struct
internal readonly record struct SlideVisualState(
double Left,
double Top,
double Width,
double Height,
double TranslationYFactor);
to a class
internal sealed record SlideVisualState(
double Left,
double Top,
double Width,
double Height,
double TranslationYFactor);
Steps To Reproduce
- Compile the app for ARM64 arch on a X64 hardware
- Install it on an ARM64 hardware.
- Press any of the arrow keys on the carousel and observe the crash.
The arrow keys 👇
Expected Behavior
Expect it to work correctly and cycle between the slides.
Version Info
.NET 10.0.11
Visual Studio 2026 latest up to date version
Windows 11 25H2 latest up to date version
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.4.0" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.3.1" />
<PackageReference Include="Microsoft.WindowsAppSDK.WinUI" Version="2.3.6" />
Directory.Build.props: https://github.com/HotCakeX/Harden-Windows-Security/blob/6ebad34955525279145353a83b6a26c2596bf6a5/AppControl%20Manager/Directory.Build.props
Additional Context
This is 100% reproducible in this tag: https://github.com/HotCakeX/Harden-Windows-Security/releases/tag/AppControlManager-v2.0.731.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced FeatureHighlightsCarouselDialog.xaml.cs and FeatureHighlightsCarouselDialog.xaml files, then reproduce the crash using the linked release and cross-architecture build steps. Compare the behavior of SlideVisualState as a readonly record struct versus a sealed record class while tracing RotateSlides(Boolean). Done means the carousel cycles between slides without an access violation on ARM64.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100