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 a potential deadlock for PtySignal::SetParent #14463

Merged
2 commits merged into from
Dec 1, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Nov 29, 2022

This changeset consists of two parts:

  • Refactor PtySignalInputThread to move more code from _InputThread
    into the various _Do* handlers. This allows us to precisely control
    console locking behavior which is the cause of this bug.
  • Add the 1-line fix to _DoSetWindowParent to unlock the console before
    calling foreign functions (SetWindowLongPtrW in this case).

This fix is theoretical in nature, based on a memory dump from an affected user
and most likely fixes: https://developercommunity.visualstudio.com/t/10199439

Validation Steps Performed

  • ConPTY tests complete. ✅

@lhecker lhecker added Product-Conpty For console issues specifically related to conpty Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Area-Remoting Communication layer between windows. Often for windowing behavior, quake mode, etc. labels Nov 29, 2022
_DoShowHide(_initialShowHide->show);
_DoShowHide(*_initialShowHide);
Copy link
Member

Choose a reason for hiding this comment

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

(for my education) why is ShowHideData a struct? Why not just make _initialShowHide an optional<unsigned short> directly?

Copy link
Member Author

@lhecker lhecker Dec 1, 2022

Choose a reason for hiding this comment

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

I suppose it was done to make the code more consistent? I'd probably would've done it the same way. (And because of that I built on this to store the struct in the optional.)

Copy link
Member

Choose a reason for hiding this comment

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

FYI We made everything structs so that they could be read directly "off the wire".

_DoShowHide(_initialShowHide->show);
_DoShowHide(*_initialShowHide);
Copy link
Member

Choose a reason for hiding this comment

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

FYI We made everything structs so that they could be read directly "off the wire".

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 1, 2022
@ghost
Copy link

ghost commented Dec 1, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 3c78e01 into main Dec 1, 2022
@ghost ghost deleted the dev/lhecker/pty-parent-deadlock branch December 1, 2022 23:13
carlos-zamora pushed a commit that referenced this pull request Dec 5, 2022
This changeset consists of two parts:
* Refactor `PtySignalInputThread` to move more code from `_InputThread`
  into the various `_Do*` handlers. This allows us to precisely control
  console locking behavior which is the cause of this bug.
* Add the 1-line fix to `_DoSetWindowParent` to unlock the console before
  calling foreign functions (`SetWindowLongPtrW` in this case).

This fix is theoretical in nature, based on a memory dump from an affected user
and most likely fixes: https://developercommunity.visualstudio.com/t/10199439

## Validation Steps Performed
* ConPTY tests complete. ✅
lhecker added a commit that referenced this pull request Dec 5, 2022
This changeset consists of two parts:
* Refactor `PtySignalInputThread` to move more code from `_InputThread`
  into the various `_Do*` handlers. This allows us to precisely control
  console locking behavior which is the cause of this bug.
* Add the 1-line fix to `_DoSetWindowParent` to unlock the console before
  calling foreign functions (`SetWindowLongPtrW` in this case).

This fix is theoretical in nature, based on a memory dump from an affected user
and most likely fixes: https://developercommunity.visualstudio.com/t/10199439

## Validation Steps Performed
* ConPTY tests complete. ✅

(cherry picked from commit 3c78e01)
DHowett pushed a commit that referenced this pull request Dec 12, 2022
This changeset consists of two parts:
* Refactor `PtySignalInputThread` to move more code from `_InputThread`
  into the various `_Do*` handlers. This allows us to precisely control
  console locking behavior which is the cause of this bug.
* Add the 1-line fix to `_DoSetWindowParent` to unlock the console before
  calling foreign functions (`SetWindowLongPtrW` in this case).

This fix is theoretical in nature, based on a memory dump from an affected user
and most likely fixes: https://developercommunity.visualstudio.com/t/10199439

## Validation Steps Performed
* ConPTY tests complete. ✅

(cherry picked from commit 3c78e01)
Service-Card-Id: 87207820
Service-Version: 1.15
DHowett pushed a commit that referenced this pull request Dec 12, 2022
This changeset consists of two parts:
* Refactor `PtySignalInputThread` to move more code from `_InputThread`
  into the various `_Do*` handlers. This allows us to precisely control
  console locking behavior which is the cause of this bug.
* Add the 1-line fix to `_DoSetWindowParent` to unlock the console before
  calling foreign functions (`SetWindowLongPtrW` in this case).

This fix is theoretical in nature, based on a memory dump from an affected user
and most likely fixes: https://developercommunity.visualstudio.com/t/10199439

## Validation Steps Performed
* ConPTY tests complete. ✅

(cherry picked from commit 3c78e01)
Service-Card-Id: 87207821
Service-Version: 1.16
@ghost
Copy link

ghost commented Dec 14, 2022

🎉Windows Terminal v1.15.3465.0 and v1.15.3466.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Dec 14, 2022

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

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Remoting Communication layer between windows. Often for windowing behavior, quake mode, etc. AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants