Skip to content

Bug: memory access violation after cross-arch NAOT compilation #2546

Description

Description

I've created a carousel for my app, here are the codes:

  1. https://github.com/HotCakeX/Harden-Windows-Security/blob/6ebad34955525279145353a83b6a26c2596bf6a5/AppControl%20Manager/CustomUIElements/FeatureHighlightsCarouselDialog.xaml.cs
  2. 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

  1. Compile the app for ARM64 arch on a X64 hardware
  2. Install it on an ARM64 hardware.
  3. Press any of the arrow keys on the carousel and observe the crash.

The arrow keys 👇

carousel

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" />

CSPROJ: https://github.com/HotCakeX/Harden-Windows-Security/blob/6ebad34955525279145353a83b6a26c2596bf6a5/AppControl%20Manager/AppControl%20Manager.csproj

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions