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 crash on settings reload #13644

Merged
1 commit merged into from
Aug 2, 2022
Merged

Fix a crash on settings reload #13644

1 commit merged into from
Aug 2, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Aug 1, 2022

07d58a8 contains a regression where the settings' Themes() property is
accessed without checking whether it's a nullptr. This can happen because
the invalid settings modal is shown with a empty settings model object.

This commit fixes the issue by deferring the update of _settings until
after we ensured that the _settings object is valid (besides warnings).

Closes #13543

Validation Steps Performed

  • Replace any string value with 123
  • Application doesn't crash ✅

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal 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-Blocking We won't ship a release like this! No-siree. labels Aug 1, 2022
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Huh. This is clever

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.

Mainly blocking over the question on the removed FAILED check. Just wanna make sure we have our bases covered.

src/cascadia/TerminalApp/AppLogic.cpp Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 1, 2022
@carlos-zamora carlos-zamora added this to the Terminal v1.16 milestone Aug 2, 2022
@lhecker lhecker force-pushed the dev/lhecker/13543-defaults-crash branch from 9a59b09 to c522cb9 Compare August 2, 2022 15:40
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 2, 2022
@lhecker lhecker requested a review from zadjii-msft August 2, 2022 15:40
@lhecker
Copy link
Member Author

lhecker commented Aug 2, 2022

@zadjii-msft @carlos-zamora With the issue Carlos found, I've chosen a new approach which should also work. This slightly changes the behavior of WT however: From now on we'll not reload any settings until after the settings.json could be successfully parsed.

@carlos-zamora
Copy link
Member

@zadjii-msft @carlos-zamora With the issue Carlos found, I've chosen a new approach which should also work. This slightly changes the behavior of WT however: From now on we'll not reload any settings until after the settings.json could be successfully parsed.

Hmm... That's not noticeable right? A user generally experiences the following behavior after updating the settings.json...

  • no errors in the JSON --> hot reload
  • lingering comma --> we're smart and we ignore the comma --> hot reload
  • valid JSON, but wrong type for a setting --> ignore the setting
  • JSON cannot be read --> fall back to defaults.json

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.

Yeah, I think this works just fine. Thanks!

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

huh. Another clever solution. Neato, thanks!

@carlos-zamora carlos-zamora added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 2, 2022
@ghost
Copy link

ghost commented Aug 2, 2022

Hello @carlos-zamora!

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 7f92207 into main Aug 2, 2022
@ghost ghost deleted the dev/lhecker/13543-defaults-crash branch August 2, 2022 16:58
@lhecker
Copy link
Member Author

lhecker commented Aug 2, 2022

Hmm... That's not noticeable right? [...]

  • valid JSON, but wrong type for a setting --> ignore the setting
  • JSON cannot be read --> fall back to defaults.json

I think the only reason it's generally not very noticeable is because we call _root->SetSettings(_settings, true) only if the settings reload was successful.

But if you check AppLogic.cpp you can see how _settings is used in a lot of other places as well. I get the feeling that this PR might fix a number of subtle bugs and not just #13543. For instance AppLogic::FindTargetWindow depends on _settings, but before this PR _settings might have been invalid.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Thanks!

@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal Preview v1.16.252 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-Settings Issues related to settings and customizability, for console or terminal 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-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.16] JSON converter error during hot reload causes crash
4 participants