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

Initialize all members of Terminal #14345

Merged
1 commit merged into from
Nov 7, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Nov 5, 2022

The following members were not initialized during construction:

  • CursorType _defaultCursorShape
  • bool _suppressApplicationTitle
  • bool _bracketedPasteMode
  • size_t _hyperlinkPatternId
  • SelectionExpansion _multiClickSelectionMode
  • til::CoordType _scrollbackLines

Unlike gcc and clang, MSVC is fairly tame when it comes to removing code
tainted by undefined behavior, so the most likely affect this had is that
we were reading uninitialized memory.

Related to #14129.

@ghost ghost added Area-Input Related to input processing (key presses, mouse, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Nov 5, 2022
@lhecker lhecker added this to the Terminal v1.17 milestone Nov 5, 2022
@@ -37,24 +37,7 @@ static std::wstring _KeyEventsToText(std::deque<std::unique_ptr<IInputEvent>>& i
}

#pragma warning(suppress : 26455) // default constructor is throwing, too much effort to rearrange at this time.
Terminal::Terminal() :
_mutableViewport{ Viewport::Empty() },
Copy link
Member

Choose a reason for hiding this comment

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

This one didn't get copied over to the header. Should we initialize it there too?

Comment on lines 364 to 365
std::unique_ptr<TextBuffer> _mainBuffer;
std::unique_ptr<TextBuffer> _altBuffer;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::unique_ptr<TextBuffer> _mainBuffer;
std::unique_ptr<TextBuffer> _altBuffer;
std::unique_ptr<TextBuffer> _mainBuffer = nullptr;
std::unique_ptr<TextBuffer> _altBuffer = nullptr;

no benefit to initializing these too? At least for consistency.

@@ -356,27 +352,27 @@ class Microsoft::Terminal::Core::Terminal final :
til::point pivot;
};
std::optional<SelectionAnchors> _selection;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::optional<SelectionAnchors> _selection;
std::optional<SelectionAnchors> _selection = std::nullopt;

this one also didn't get carried over from the cpp.

Copy link
Member

Choose a reason for hiding this comment

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

optionals are technically .. ah you probably talked about this

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

discussed offline. We good.

@lhecker lhecker added the AutoMerge Marked for automatic merge by the bot when requirements are met label Nov 7, 2022
@ghost
Copy link

ghost commented Nov 7, 2022

Hello @lhecker!

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 a798a60 into main Nov 7, 2022
@ghost ghost deleted the dev/lhecker/14129-fix-uninitialized-members branch November 7, 2022 23:16
DHowett pushed a commit that referenced this pull request Dec 1, 2022
The following members were not initialized during construction:
* `CursorType _defaultCursorShape`
* `bool _suppressApplicationTitle`
* `bool _bracketedPasteMode`
* `size_t _hyperlinkPatternId`
* `SelectionExpansion _multiClickSelectionMode`
* `til::CoordType _scrollbackLines`

Unlike gcc and clang, MSVC is fairly tame when it comes to removing code
tainted by undefined behavior, so the most likely affect this had is that
we were reading uninitialized memory.

Related to #14129.

(cherry picked from commit a798a60)
Service-Card-Id: 86826740
Service-Version: 1.15
DHowett pushed a commit that referenced this pull request Dec 1, 2022
The following members were not initialized during construction:
* `CursorType _defaultCursorShape`
* `bool _suppressApplicationTitle`
* `bool _bracketedPasteMode`
* `size_t _hyperlinkPatternId`
* `SelectionExpansion _multiClickSelectionMode`
* `til::CoordType _scrollbackLines`

Unlike gcc and clang, MSVC is fairly tame when it comes to removing code
tainted by undefined behavior, so the most likely affect this had is that
we were reading uninitialized memory.

Related to #14129.

(cherry picked from commit a798a60)
Service-Card-Id: 86603221
Service-Version: 1.16
@zadjii-msft zadjii-msft linked an issue Dec 1, 2022 that may be closed by this pull request
@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-Input Related to input processing (key presses, mouse, 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-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Strange bug with pasting sudo password via SSH on Linux 🐧
4 participants