Skip to content

Multi-window batch teardown 0xC0000005 ACCESS_VIOLATION at process exit (general dispose-ordering) #647

Closed

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

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

Activity

  1. azchohfi commented on Jun 23, 2026

    @azchohfi
    CollaboratorAuthor

    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 0xC0000005 in BackdropApplier.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.SystemBackdrop regardless of backdrop kind, AVing on the already-torn-down owner.

    So the 0xC0000005 umbrella now has at least two distinct native objects faulting at multi-window teardown:

    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_OwnedChild fixture plus an in-fixture comment documenting why the cascade itself can't be selftested.

    Proposed fix direction refinement: BackdropApplier.Reset() should null SystemBackdrop only 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.

  2. azchohfi commented on Jun 23, 2026

    @azchohfi
    CollaboratorAuthor

    Concrete, reproducible trigger identified (from #417 / PR #642 CI debugging).

    The probabilistic 0xC0000005 in the single-process selftest batch was reproduced and root-caused in a docking fixture: a floating window was closed twice — once implicitly by DockFloatingWindow.StashReasonAndClose (the dock-back auto-close) and then again by the fixture's finally { window.Close(); }. That double-close on an already-torn-down window is the multi-window teardown AV trigger.

    Key confirmations:

    • It's cross-fixture poisoning: all selftest fixtures run in ONE Host process (sequential --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.
    • It's probabilistic (05:35 run passed, 06:39 failed with identical fixtures) — consistent with a teardown-ordering race across windows.
    • Same class as the TitleBar explicit false close path can corrupt WinUI title-bar teardown #537 single-control heap corruption and the BackdropApplier.Reset() AV noted above: a native window/AppWindow/interop object being released after its window is already gone.

    The #417 fix was test-side only (subscribe Closed, flag, skip the redundant finally close) — 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.

  3. added 2 commits that reference this issue on Jun 23, 2026
  4. added 2 commits that reference this issue on Jun 26, 2026
    1c4c86a
    8fed735
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions