Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening the debug tap #11445

Merged
merged 2 commits into from
Oct 6, 2021
Merged

Fix opening the debug tap #11445

merged 2 commits into from
Oct 6, 2021

Conversation

zadjii-msft
Copy link
Member

It's possible that we're about to be started, before
our paired connection is started. Both will get Start()'ed when
their owning TermControl is finally laid out. However, if we're
started first, then we'll immediately start printing to the other
control as well, which might not have initialized yet. If we do
that, we'll explode.

Instead, wait here until the other connection is started too,
before actually starting the connection to the client app. This
will ensure both controls are initialized before the client app
is.

Fixes #11282

Tested: Opened about 100 debug taps. They all worked. :shipit:

@ghost ghost added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. labels Oct 6, 2021
@@ -1025,7 +1025,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation

TerminalConnection::ConnectionState ControlCore::ConnectionState() const
{
return _connection.State();
return _connection ? _connection.State() : TerminalConnection::ConnectionState::Closed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer NotConnected here -- technically (poorly documented) connections should only move one direction (NotConn->Connecting->Connected->Closing->Closed or ...->Failed (at any point))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I actually hit in teardown, weirdly enough. A control closed, which bubbled up and out to the pane, who asked the control what its ConnectionState() was, but the _connection had already been swapped with nullptr in the teardown. So I figured the connection was "closed" at this point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty, sorry, not fully paged in 😄

// their owning TermControl is finally laid out. However, if we're
// started first, then we'll immediately start printing to the other
// control as well, which might not have initialized yet. If we do
// that, we'll explode.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we think about making it so that's not a problem? Should TermControl buffer so Connections (eventually, 3p connections) don't need to "slow down"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that TC calls Start before it is really "ready" to receive text honestly..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, TC is ready for the text. The issue is that in this case, there's a connection that needs two different TC's to be ready. So this is about syncing up those two.

I considered having TC start by buffering the output internally, but I figured the options were:

  • do that which might take a few days and miss 1.12 (and mean debugtap won't be usable for debugging in 1.12)
  • do this and get it working for 1.12

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang, you're right. Sorry. Yeah.

I wonder, then, whether DebugTapConn should buffer. In the future. Thanks!

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 6, 2021
@DHowett
Copy link
Member

DHowett commented Oct 6, 2021

@msftbot merge this in 2 linux

@ghost
Copy link

ghost commented Oct 6, 2021

Hello @DHowett!

I think you told me that you expect at least 2 approvals before I perform the merge, but I am not confident that I have understood you correctly.

Please try rephrasing your instruction to me.

@DHowett
Copy link
Member

DHowett commented Oct 6, 2021

Why did my fingers type that?

@DHowett DHowett merged commit bd8bfa1 into main Oct 6, 2021
@DHowett DHowett deleted the dev/migrie/b/11282-debug-tap branch October 6, 2021 21:11
@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal Preview v1.12.2922.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.12] Opening the debug tap instantly crashes the terminal
4 participants