[PR #13876] An attempted fix for the SignalTextChanged crash #29800

Open
opened 2026-01-31 09:36:57 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13876

State: closed
Merged: Yes


This is conjecture - I was totally unable to repro the original crash here.
Based on the stacks in MSFT:39994969, it looks like we try to fire off a
RaiseAutomationEvent, which calls through UIA core, eventually to the point of
calling ComPtr<WUX::Automation::Peers::IAutomationPeer>::{dtor}. I'm guessing
based on the stacks that the TermControl has already been released and cleaned
up. However, the lambda in the RunAsync calls here only takes a ref to the
TCAP. The TCAP has an outstanding reference (maybe on the other side of the UIA
fence), and gets successfully resolved as strong, but when calling to
RaiseAutomationEvent, the owner we passed in is gonezo.

This explicitly passes a weak_ref to TermControlAutomationPeer, rather than
a raw ptr, so we can actually check if the control is still alive before we
dereference it. If it is, great, we've got a strong ref to it now and it won't
get torn down.

Again, this is hearsay. Without a repro, the only way we can confirm this is
gone is by just hoping the crashes go away. 🤞

  • Might close #13357 (we'll reopen if it doesn't?)
  • narrator still works
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13876 **State:** closed **Merged:** Yes --- This is conjecture - I was totally unable to repro the original crash here. Based on the stacks in MSFT:39994969, it looks like we try to fire off a `RaiseAutomationEvent`, which calls through UIA core, eventually to the point of calling `ComPtr<WUX::Automation::Peers::IAutomationPeer>::{dtor}`. I'm guessing based on the stacks that the TermControl has already been released and cleaned up. However, the lambda in the `RunAsync` calls here only takes a ref to the TCAP. The TCAP has an outstanding reference (maybe on the other side of the UIA fence), and gets successfully resolved as strong, but when calling to `RaiseAutomationEvent`, the `owner` we passed in is gonezo. This explicitly passes a `weak_ref` to `TermControlAutomationPeer`, rather than a raw ptr, so we can actually check if the control is still alive before _we_ dereference it. If it is, great, we've got a strong ref to it now and it won't get torn down. Again, this is hearsay. Without a repro, the only way we can confirm this is gone is by just hoping the crashes go away. 🤞 * Might close #13357 (we'll reopen if it doesn't?) * narrator still works
claunia added the pull-request label 2026-01-31 09:36:57 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29800