Repository navigation
Description
Summary
Running the full selftest suite (1204 fixtures) in a single process exits with 0xC0000005 (ACCESS_VIOLATION) at process teardown, after # Total failures: 0 — i.e. every fixture passes; the process faults only while tearing down many windows at exit. Independently observed by two sessions (the #417 docking tear-off batch and the #537 TitleBar work).
Pre-existing — not a regression
Reproduced on baseline origin/main (pre-change files checked out, rebuilt, ran). Each affected fixture passes individually; the fault only manifests in the multi-window batch run. The docking tear-off selftest batch is almost certainly a smaller subset that trips the same thing.
Distinct from #537
- TitleBar explicit false close path can corrupt WinUI title-bar teardown #537 =
0xC0000374HEAP_CORRUPTION, a single object — the WinUIMicrosoft.UI.Xaml.Controls.TitleBarcontrol tearing down while its window is inExtendsContentIntoTitleBar=falsemode. Deterministic, single-window. Fixed in PR fix(hosting): flip ExtendsContentIntoTitleBar before close to stop TitleBar heap corruption (#537) #646. - This issue =
0xC0000005ACCESS_VIOLATION, multi-window, after N fixtures. Different fault class. - The docking floating windows can't be hitting the TitleBar explicit false close path can corrupt WinUI title-bar teardown #537 mechanism:
DockFloatingWindow.cs:123-127explicitly setsExtendsContentIntoTitleBar=trueand deliberately does not use the WinUITitleBarcontrol — it wiresWindow.SetTitleBar(Border dragRegion)onLoadedinstead. So_titleBarControlPresentis false for those windows andPrepareTitleBarForClose()is a no-op there. PR fix(hosting): flip ExtendsContentIntoTitleBar before close to stop TitleBar heap corruption (#537) #646 neither addresses nor regresses this AV.
Suspected root class
Both faults live under the same umbrella: native window / AppWindow / title-bar-interop teardown ordering across multiple windows in one process. The 0xC0000005 is most likely a SetTitleBar/AppWindow interop object (or the WindowMonitor/WindowMessageMonitor subclass chain) being released after its window/AppWindow is already gone, racing across windows at process exit — a general dispose-ordering problem, distinct from the single-control-mode heap corruption.
This is the same family as the residual gaps flagged in PR #646's own pr-review (ReactorApp.Exit/SafeExit bypass, owner cascade only prepping direct children, ReactorWindow.Dispose bypass): "teardown ordering isn't deterministic/idempotent across all exit/close/dispose paths."
Proposed direction
A general hardening: route every window through one deterministic, idempotent pre-native-destroy teardown on every close/exit/dispose path, and unregister interop (SetTitleBar / WindowMessageMonitor subclass) idempotently. This would be the right home for both #537's residual gaps and this docking-batch AV.
Next step
A focused repro that instruments the docking tear-off batch + the WindowMessageMonitor/SetTitleBar teardown to trace exactly which native object faults.
Related
- TitleBar explicit false close path can corrupt WinUI title-bar teardown #537 / PR fix(hosting): flip ExtendsContentIntoTitleBar before close to stop TitleBar heap corruption (#537) #646 (TitleBar ECITB=false heap corruption — narrow fix)
- Docking: OnFloatingWindowClosed can't be distinguished from cross-window dock-back #417 / PR Add DockFloatingCloseReason discriminator to floating-window close event (#417) #642 (docking dock-back close-reason — observed the batch AV)
- Spec 054: Windowing evolution #536 (prior TitleBar selftest mitigation)
Activity
azchohfi commentedon Jun 23, 2026
Second concrete native object identified under this umbrella, from the #537 / PR #646 work.
When building a real parent-close cascade selftest (ECITB=false child-with-TitleBar, then close the parent), the process crashes
0xC0000005inBackdropApplier.Reset()→set_SystemBackdrop. This was proven independent of #537: swapping the child to a plain no-TitleBar component (so the TitleBar prep becomes a complete no-op) still crashes identically.Root: closing an owner that still owns a LIVE child is an unsupported teardown order in this harness —
BackdropApplier.Reset()unconditionally nulls_window.SystemBackdropregardless of backdrop kind, AVing on the already-torn-down owner.So the
0xC0000005umbrella now has at least two distinct native objects faulting at multi-window teardown:SystemBackdrop/BackdropApplier.Reset()(this sighting + the Docking: OnFloatingWindowClosed can't be distinguished from cross-window dock-back #417 docking batch)SetTitleBar/AppWindow interop orWindowMessageMonitorsubclass chain (original suspicion)Consequence for testability: the owner-close cascade path can only be exercised at the E2E tier (chrome/Alt+F4) today; it is not headlessly selftestable until this dispose-ordering AV is fixed. PR #646 ships a stable child-first
TitleBar_OwnedChildfixture plus an in-fixture comment documenting why the cascade itself can't be selftested.Proposed fix direction refinement:
BackdropApplier.Reset()should nullSystemBackdroponly when the window/AppWindow is still alive (guard against a torn-down owner), as part of the general "deterministic idempotent pre-native-destroy teardown on every path" hardening.azchohfi commentedon Jun 23, 2026
Concrete, reproducible trigger identified (from #417 / PR #642 CI debugging).
The probabilistic
0xC0000005in the single-process selftest batch was reproduced and root-caused in a docking fixture: a floating window was closed twice — once implicitly byDockFloatingWindow.StashReasonAndClose(the dock-back auto-close) and then again by the fixture'sfinally { window.Close(); }. That double-close on an already-torn-down window is the multi-window teardown AV trigger.Key confirmations:
--self-test), so the heap/AppWindow corruption from the double-close surfaced later as an unrelated fixture (OptionalEchoStrandRegression) reporting "fixture emitted no TAP checks". This is exactly the "passes individually, fails in batch" signature this issue tracks.The #417 fix was test-side only (subscribe
Closed, flag, skip the redundantfinallyclose) — it removed the fixture's double-close but does not harden the framework against a double/late close in general. That general hardening is this issue's scope:ReactorWindow.Close()/Dispose()should be idempotent and a no-op (not re-enter native teardown) once the window has already been closed/destroyed, so a second close can't corrupt the heap. Combined with the BackdropApplier-guard and the "one deterministic pre-native-destroy teardown on every path" direction, that's the full fix surface.Harden TitleBar close-prep guard + add dispose/exit/recursion coverage (
Apply #647 pr-review findings: shared primary election + regression s…
Merge pull request #673 from microsoft/azchohfi-fix-647-multiwindow-d…
Fix #680: hard-exit the self-test harness to avoid framework teardown…
Own the dispatcher loop unconditionally, not per policy
Make ShutdownPolicy govern process lifetime (#1204) (#1205)