terminal/src/cascadia/TerminalControl
James Holderness 40ebe5ab54
Fix crash in terminal when tab closed while data is being output (#8982)
If there is data being output when a tab is closed, that can sometimes
result in the application crashing, because the renderer may still be in
use at the time is it destroyed. This PR attempts to prevent that from
happening by adding a lock in the `TermControl::Close` method.

What we're trying to prevent is the connection thread still being
active, and potentially accessing the renderer, after it has been
destroyed. So by acquiring the terminal lock in `TermControl::Close`,
after we've stopped accepting new output, we can be sure that the
connection thread is no longer active (it holds the lock while it is
processing output). So once we've acquired and released the lock, it
should be safe to tear down and destroy the renderer.

## Validation Steps Performed

While this crash is difficult to reproduce in general usage, it occurred
quite frequently when testing my `DECPS` implementation (there is some
tricky thread synchronisation, which seems more likely to trigger the
issue). With this patch applied, though, those crashes have stopped
occurring.

I've also stepped through the shutdown code in the debugger, manually
freezing threads to get them aligned in the right way to trigger the
crash (as explained in issue #8734). Again with the patch applied, I can
no longer get the crash to occur.

Closes #8734
2021-02-01 21:28:47 +00:00
..
Resources/en-US Implement user-specified pixel shaders, redux (#8565) 2020-12-15 20:40:22 +00:00
IControlSettings.idl Implement user-specified pixel shaders, redux (#8565) 2020-12-15 20:40:22 +00:00
IKeyBindings.idl Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
IMouseWheelListener.idl Pass mouse button state into HandleMouse instead of asking win32 (#6765) 2020-08-07 16:21:09 -07:00
init.cpp Hook up the WIL fallback error tracer in Terminal (#7864) 2020-10-09 22:20:12 +00:00
KeyChord.cpp Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
KeyChord.h Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
KeyChord.idl Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
packages.config Update C++/WinRT to 2.0.201017.1 (#8061) 2020-10-27 20:15:30 +00:00
pch.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
pch.h Exclude more rarely-used stuff from Windows headers (#8513) 2020-12-11 19:35:23 +00:00
SearchBoxControl.cpp Teach Find command to populate the search box with selected text (#8521) 2020-12-10 01:24:16 +00:00
SearchBoxControl.h Teach Find command to populate the search box with selected text (#8521) 2020-12-10 01:24:16 +00:00
SearchBoxControl.idl Teach Find command to populate the search box with selected text (#8521) 2020-12-10 01:24:16 +00:00
SearchBoxControl.xaml Make Terminal look great in High Contrast (#6833) 2020-07-08 12:08:08 -07:00
TermControl.cpp Fix crash in terminal when tab closed while data is being output (#8982) 2021-02-01 21:28:47 +00:00
TermControl.h Teach terminal to hide mouse while typing (#8629) 2021-01-21 01:17:59 +00:00
TermControl.idl Teach terminal to hide mouse while typing (#8629) 2021-01-21 01:17:59 +00:00
TermControl.xaml Display URI tooltip, render dashed/solid underline for links (#7420) 2020-09-10 14:59:56 -07:00
TermControlAutomationPeer.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
TermControlAutomationPeer.h Define Automation Properties for TermControl (#4732) 2020-02-27 16:37:56 -08:00
TermControlAutomationPeer.idl Attach UiaRenderer and Fire Selection Changed Events (#2989) 2019-12-11 13:52:49 -08:00
TerminalControl.def Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
TerminalControl.vcxproj Remove all our path antics; force native projects to bin/, obj/ (#8062) 2020-10-27 15:00:41 -07:00
TerminalControl.vcxproj.filters Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
ThrottledFunc.cpp Set memory order on slow atomics (#6920) 2020-07-17 17:11:45 +00:00
ThrottledFunc.h Update _TerminalCursorPositionChanged to use ThrottledFunc (#6492) 2020-06-23 14:05:40 -07:00
TSFInputControl.cpp Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
TSFInputControl.h Add font weight options (#6048) 2020-05-20 20:17:17 +00:00
TSFInputControl.idl Add font weight options (#6048) 2020-05-20 20:17:17 +00:00
TSFInputControl.xaml Allow IME Text Wrapping (#5005) 2020-03-19 19:15:13 +00:00
XamlUiaTextRange.cpp hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00
XamlUiaTextRange.h hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00