Terminal: Crashes when a custom scaling size is set

Created on 27 Nov 2019  路  7Comments  路  Source: microsoft/terminal

Environment

Windows build number: Microsoft Windows [Version 10.0.19033.1]
Windows Terminal version (if applicable): 0.7.3291.0, also built from master (7bcb060)

Steps to reproduce

  1. Set a custom scaling factor in Settings > System > Display > "Advanced scaling settings", for example:

    image

  2. Start the terminal

Expected behavior

The terminal should start

Actual behavior

The terminal crashes almost immediately after loading a blank screen.

In trying to fix this I've reinstalled and also removed profiles.json to get a fresh one. Afterwards I attempted to debug, and got the following call stack:

TerminalControl.dll!gsl::details::terminate() Line 127  C++
TerminalControl.dll!gsl::details::throw_exception<gsl::narrowing_error>(gsl::narrowing_error && __formal) Line 136  C++
TerminalControl.dll!gsl::narrow<float,double>(double u) Line 126    C++
TerminalControl.dll!ScaleRect(winrt::Windows::Foundation::Rect rect, double scale) Line 31  C++
TerminalControl.dll!winrt::Microsoft::Terminal::TerminalControl::implementation::TSFInputControl::_layoutRequestedHandler(winrt::Windows::UI::Text::Core::CoreTextEditContext sender, const winrt::Windows::UI::Text::Core::CoreTextLayoutRequestedEventArgs & args) Line 164   C++

Based on this I realized my display's scaling factor had been set to a custom value (115% or something). I changed it back to the default 100% and it started fine.

Feedback Hub link: https://aka.ms/AA6q09q

Area-TerminalControl Issue-Bug Needs-Tag-Fix Priority-1 Product-Terminal Resolution-Fix-Committed Severity-Crash

Most helpful comment

No problem editing that file, it鈥檚 definitely one of ours :)

All 7 comments

Fascinating! Thanks. This might explain a number of the crash-on-startup issues.

I had a look through the code implicated in the stack trace, and it's a classic floating point comparison failure. ScaleRect takes a double which it tries to cast to a float using gsl::narrow. The exception is emitted from gsl::narrow after a failed comparison between floating point values (float and double). After writing a ScaleRect which only uses the gsl::narrow_cast (which just wraps a static_cast) the crash disappears.

ScaleRect is coming from Utils.h in External Dependencies in WinRTUtils and TerminalControl (when viewed in VS19). Would there be any problem editing Utils.h? Would the new ScaleRect function be better?

No problem editing that file, it鈥檚 definitely one of ours :)

Great, I'll PR the fix

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

Handy links:

Just installed Version: 0.7.3382.0 and can confirm that it's all working now. Thanks for the quick response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miniksa picture miniksa  路  3Comments

xmm1989218 picture xmm1989218  路  3Comments

carlos-zamora picture carlos-zamora  路  3Comments

Wid-Mimosa picture Wid-Mimosa  路  3Comments

waf picture waf  路  3Comments