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

Windows Terminal crashes when a profile's icon URL or background is unparseable/invalid #2329

Closed
AdamDanischewski opened this issue Aug 7, 2019 · 20 comments · Fixed by #2376 or #4194
Labels
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. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Severity-Crash Crashes are real bad news.
Milestone

Comments

@AdamDanischewski
Copy link

I got the latest from choco and set up an Ubuntu terminal entry. I found that if I put a garbage URL in the profiles.json icon setting entry it crashes Windows Terminal and WT won't start thereafter.

That probably shouldn't happen, though technically low priority its probably making WT look fragile.

To repeat this behavior simply remove "ms-appx:" from any icon path.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 7, 2019
@carlos-zamora carlos-zamora 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. Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. and removed Needs-Tag-Fix Doesn't match tag requirements labels Aug 7, 2019
@carlos-zamora carlos-zamora added this to the Terminal 1908.1 milestone Aug 7, 2019
@DHowett-MSFT
Copy link
Contributor

Yes, this is a good followup to #1468

@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Aug 8, 2019
@DHowett-MSFT DHowett-MSFT changed the title Bad Icon Url Crashes Windows Terminal - Then WT Fails To Start Windows Terminal crashes when a profile's icon URL is unparseable/invalid Aug 8, 2019
@ghost ghost added the In-PR This issue has a related PR label Aug 9, 2019
@AdamDanischewski
Copy link
Author

AdamDanischewski commented Aug 9, 2019

#622 (There should be an error dialog for incorrect settings instead of just crashing) references #886 (Cannot run deployed application (winrt::hresult_error when debugging)) and vice versa - both are closed yet both underlying issues still linger.

Sidenote: Tell MS to make Visual Studio free.

@DHowett-MSFT
Copy link
Contributor

@AdamDanischewski

make Visual Studio free

Like Community edition?

@AdamDanischewski
Copy link
Author

Lol, yea, I meant Professional - I haven't used VS before but I see Community VS is full featured. I'm surprised these critical bugs aren't getting fixed quicker.

I've been out of the loop for a few years touristing, interesting to see how far MS has embraced Open Source. Once I get a dev env set up I'll probably contribute.

@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Aug 14, 2019
@ghost
Copy link

ghost commented Aug 27, 2019

🎉This issue was addressed in #2376, which has now been successfully released as Windows Terminal Preview v0.4.2382.0.:tada:

Handy links:

@AdamDanischewski
Copy link
Author

This issue is still not fixed as of v0.4.2382.0 - please re-open and de-merge this issue from #2376 since #2376 is fixed and this issue is not.

@DHowett-MSFT
Copy link
Contributor

Interesting. I had to try about six different variants before I was able to find one that would crash.

@DHowett-MSFT DHowett-MSFT reopened this Sep 3, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 3, 2019
@DHowett-MSFT DHowett-MSFT removed the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Sep 3, 2019
@mdtauk
Copy link

mdtauk commented Sep 3, 2019

There should be a default icon that a profile will revert to, when the specified icon is not found

@zadjii-msft
Copy link
Member

Interesting. I had to try about six different variants before I was able to find one that would crash.

@DHowett-MSFT Mind sharing what URL variant caused the crash? Or filing a new issue with that variant?

@DHowett-MSFT
Copy link
Contributor

"icon": "/beeftown.png",

It can't construct a Uri.

Exception thrown at 0x00007FFCF5715369 (KernelBase.dll) in WindowsTerminal.exe:
WinRT originate error - 0x80070057 : '/beeftown.png is not a valid absolute URI.'.

@thomthom
Copy link

thomthom commented Oct 1, 2019

I just ran into this when I tried to use environmental variables in the icon path.

This will crash in 0.5.2681.0

"icon": "%HOMEPATH%\\Dropbox\\terminal\\VSWinIcon_100x.png",

This will not.

"icon": "C:\\Users\\Thomas\\Dropbox\\terminal\\VSWinIcon_100x.png",

I realise that env variables might not be supported for icons. But just wanted to throw in my crash scenario.

@mkitzan
Copy link
Contributor

mkitzan commented Dec 16, 2019

Does this issue still repro? I can't get a crash with any of the icon paths. Let me know if you've got an icon path which can consistently crash WT, and any specific repro steps required.

@Reelix
Copy link

Reelix commented Dec 16, 2019

I posted in #2376 which got merged into this issue. Using my original steps, I am unable to reproduce this issue in 0.7.3451.0 so it seems to have been fixed.

@mkitzan
Copy link
Contributor

mkitzan commented Dec 16, 2019

Phantom fixes, nice. Would be good if others in the thread who had repros after #2376 was merged could confirm too.

@thomthom
Copy link

I'm not able to reproduce this either now.

@DHowett-MSFT
Copy link
Contributor

Fascinating. I'm going to close this for now, but we'll keep our eyes peeled. Thanks for the confirmations!

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Dec 18, 2019
@DHowett-MSFT DHowett-MSFT reopened this Dec 19, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Dec 19, 2019
@DHowett-MSFT DHowett-MSFT changed the title Windows Terminal crashes when a profile's icon URL is unparseable/invalid Windows Terminal crashes when a profile's icon URL or background is unparseable/invalid Dec 19, 2019
@zadjii-msft
Copy link
Member

We're reactivating this from discussion in #4002:

Windows build number: Microsoft Windows NT 10.0.19041.0
Windows Terminal version (if applicable): 0.7.3451.0

Steps to reproduce

In profiles.json under a profile, add a background image path that references the home directory ~.

{
    ...
    "profiles": [
        {
            "name": "Windows PowerShell",
            "backgroundImage": "~/Pictures/Console/PowerShell.png",
        }
    ...
}

Expected behavior

Should not crash. Should show the expected background image.

Actual behavior

Windows Terminal crash at startup.

@mkitzan
Copy link
Contributor

mkitzan commented Jan 9, 2020

The particular instance of this crash from #4002 is due to SelectionBackground() in the UpdateSettings event throwing due to the file path. Edit: was not able to repro this in a stack trace recently

Rather than defensively catching an exception, I wonder if it would make sense to validate the media associated with a profile somewhere during the profile creation process. Then we could intercept the issue (error page, inserting some default media...) before any event is even launched.

@ghost ghost added the In-PR This issue has a related PR label Jan 13, 2020
DHowett-MSFT pushed a commit that referenced this issue Jan 17, 2020
WT crashes when an unparseable/invalid `backgroundImage` or `icon`
resource path is provided in `profiles.json`. This PR averts the crash
by the validating and correcting resource paths as a part of the
`_ValidateSettings()` function in `CascadiaSettings`.
`_ValidateSettings()` is run on start up and any time `profiles.json` is
changed, so a user can not change a file path and avoid the validation
step. 

When a bad `backgroundImage` or `icon` resource path is detected, a
warning screen will be presented.

References #4002, which identified a consistent repro for the crash.

To validate the resource, a `Windows::Foundation::Uri` object is
constructed with the path. The ctor will throw if the resource path is
invalid. Whether or not this validation method is robust enough is a
subject worth review. The correction method for when a bad resource path
is detected is to reset the `std::optional<winrt::hstring>` holding the
file path. 

The text in the warning display was cribbed from the text used when an
invalid `colorScheme` is used. Whether or not the case of a bad
background image file path warrants a warning display is a subject worth
review.

Ensured the repro steps in #4002 did not trigger a crash. Additionally,
some potential backdoor paths to a crash were tested: 

- Deleting the file of a validated background image file path
- Changing the actual file name of a validated background image file
  path
- Replacing the file of a validated background image file path with a
  non-image file (of the same name)
- Using a non-image file as a background image

In all the above cases WT does not crash, and instead defaults to the
background color specified in the profile's `colorScheme`. This PR does
not implement this recovery behavior (existing error catching code
does).

Closes #2329
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Jan 17, 2020
DHowett-MSFT pushed a commit that referenced this issue Jan 24, 2020
WT crashes when an unparseable/invalid `backgroundImage` or `icon`
resource path is provided in `profiles.json`. This PR averts the crash
by the validating and correcting resource paths as a part of the
`_ValidateSettings()` function in `CascadiaSettings`.
`_ValidateSettings()` is run on start up and any time `profiles.json` is
changed, so a user can not change a file path and avoid the validation
step.

When a bad `backgroundImage` or `icon` resource path is detected, a
warning screen will be presented.

References #4002, which identified a consistent repro for the crash.

To validate the resource, a `Windows::Foundation::Uri` object is
constructed with the path. The ctor will throw if the resource path is
invalid. Whether or not this validation method is robust enough is a
subject worth review. The correction method for when a bad resource path
is detected is to reset the `std::optional<winrt::hstring>` holding the
file path.

The text in the warning display was cribbed from the text used when an
invalid `colorScheme` is used. Whether or not the case of a bad
background image file path warrants a warning display is a subject worth
review.

Ensured the repro steps in #4002 did not trigger a crash. Additionally,
some potential backdoor paths to a crash were tested:

- Deleting the file of a validated background image file path
- Changing the actual file name of a validated background image file
  path
- Replacing the file of a validated background image file path with a
  non-image file (of the same name)
- Using a non-image file as a background image

In all the above cases WT does not crash, and instead defaults to the
background color specified in the profile's `colorScheme`. This PR does
not implement this recovery behavior (existing error catching code
does).

Closes #2329

(cherry picked from commit 77dd51a)
@ghost
Copy link

ghost commented Jan 27, 2020

🎉This issue was addressed in #4194, which has now been successfully released as Windows Terminal Preview v0.8.10261.0.:tada:

Handy links:

@ghost
Copy link

ghost commented Feb 13, 2020

🎉This issue was addressed in #4194, which has now been successfully released as Windows Terminal Preview v0.9.433.0.:tada:

Handy links:

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 Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Severity-Crash Crashes are real bad news.
Projects
None yet
9 participants