Skip to content

Python WinUI smoke crashes during immediate XAML teardown on ARM64 #116

Description

@lei9444

Problem Description

samples/python/winui-hello-world/run.ps1 -Smoke creates a WinUI Application, activates a Window containing StackPanel/Button/TextBlock controls, then closes it from the OnLaunched callback. The expected success message is printed, but process teardown crashes in Microsoft.UI.Xaml.Controls.dll with 0xC0000005.

python-winui-hello-ok Hello from dynwinrt (1)
Windows fatal exception: access violation

Current thread ...
  File "samples/python/winui-hello-world/app.py", line 51 in run

Windows Error Reporting identifies Microsoft.UI.Xaml.Controls.dll, exception 0xc0000005, offset 0x138ec.

This is not a recent projection regression: an isolated ARM64 build of commit fd0c63d7245ed05e7ba95e53e66875774b8e95fe, which introduced the sample, reproduces the same crash.

Minimization results:

  • metadata-provider Application with no controls: exits successfully
  • creating/releasing XamlControlsResources, including through native RoActivateInstance: crashes during process teardown
  • creating actual StackPanel/Button controls without default Fluent resources: crashes during process teardown
  • Loaded, LayoutUpdated, and first CompositionTarget.Rendered callbacks do not provide a safe immediate-close point
  • DispatcherQueueTimer delays from 1–5 seconds are nondeterministic and are not an acceptable fix
  • normal interactive samples that remain open and are later closed by a user work normally

No fixed-delay or forced-process-termination workaround was committed.

Steps To Reproduce

  1. Use Windows ARM64 with ARM64 CPython 3.13 and Windows App SDK 2.3.
  2. Build/install the current dynwinrt Python runtime and dynwinrt-codegen.
  3. Generate samples/python/winui-hello-world using WinUI metadata 2.3.0, Foundation 2.3.5 ARM64 bootstrap, and matching reference WinMDs.
  4. Run:
.\samples\python\winui-hello-world\run.ps1 -Python <arm64-python> -Smoke -Major 2 -Minor 3
  1. Observe the success message followed by process exit -1073741819 (0xC0000005).

The same failure also occurs with matching Windows App SDK 2.4 assets.

Expected Results

The smoke test should close the Window, release projected values before apartment teardown, and exit with code 0 without an access violation. The fix should use a deterministic WinUI lifecycle boundary rather than a sleep or forced process termination.

Component

Python bindings (dynwinrt)

Windows SDK Version

10.0.26100

Environment

  • OS: Windows 11 ARM64 build 28020
  • Rust: 1.97.1
  • Python: CPython 3.13.15 ARM64
  • Windows SDK metadata: 10.0.26100.0
  • Windows App SDK tested: 2.3 and 2.4
  • Faulting module: Microsoft.UI.Xaml.Controls.dll

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions