Repository: terminal
Issue: Audit `FAIL_FAST`s across the code
Labels: Product-Conhost,Severity-Crash,Needs-Tag-Fix,Area-CodeHealth

> Back in 2018 we switched every `NTASSERT`/`ASSERT`/`NT_ASSERT` in these components to a `FAIL_FAST`, unequivocally, because if we cared enough to check it, we should care enough to die for it.
> I think that’s good and valuable, and it has its place.
>
> Now that these components are shared with Terminal (who seeks to host multiple copies of each of them in parallel), and now that a11y has taken a bigger bet on them performing sanely and safely,
> I’m wondering if we should scale back a little bit on the take down the entire process if something lifts off into space stance.
>
> We’re seeing a good number of crashes due to accessibility that I think should just be “oh, the API returned an error code, NVDA can recover”. We once saw reports that resizing the window when an unexpected DBCS half lands in the buffer (#4907) caused a crash.
>
> They’re programming errors, for sure, but our users probably want things to be more reliable.

Should, or could, we surface those as exceptions and let the caller recover wherever possible?
Should we just internally recover?

Let's find out.

---

Generated as of 2022-10-27 ab04067e49a9cf9eee36335d46eefbe13db72050

<details>
<summary>How did I generate this?</summary>

```powershell
rg -n FAIL_FAST_IF\`( --no-heading | % {
	$p=$_ -split ":";
	$pa=$p[0] -replace "\\","/";
	$ln=$p[1];
	[pscustomobject]@{File=$pa;Line=$ln}
} | group File | sort -Descending Count | % {
	"## $($_.Name)`n";
	$_.Group | % {
		"https://github.com/microsoft/terminal/blob/$(git rev-parse HEAD)/src/$($_.File)#L$($_.Line)"
	};
	"`n"
}
```
</details>

---

## host/screenInfo.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L193
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L382-L383
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L402-L403
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L421-L422
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L453-L454
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L472-L473
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L600
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L905-L907
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/screenInfo.cpp#L1161


## host/cmdline.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L284
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L448
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L483
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L519
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L651
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L665
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L677
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L685
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L766
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/cmdline.cpp#L1000


## host/_stream.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L252
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L429
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L608
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L664
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L974-L979
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/_stream.cpp#L1187


## host/inputBuffer.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputBuffer.cpp#L376
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputBuffer.cpp#L513-L518
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputBuffer.cpp#L717-L718
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputBuffer.cpp#L784
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputBuffer.cpp#L785


## propsheet/fontdlg.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L704
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L891
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L1143
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L1355
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L1498
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/fontdlg.cpp#L1590


## host/utils.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/utils.cpp#L176-L179
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/utils.cpp#L231-L232


## interactivity/win32/icon.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/icon.cpp#L238-L241
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/icon.cpp#L265
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/icon.cpp#L288
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/icon.cpp#L320


## host/readDataCooked.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataCooked.cpp#L323
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataCooked.cpp#L330-L333
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataCooked.cpp#L1079


## host/settings.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/settings.cpp#L355-L358


## host/history.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/history.cpp#L41
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/history.cpp#L66
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/history.cpp#L92
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/history.cpp#L197


## host/srvinit.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/srvinit.cpp#L827-L829


## host/misc.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/misc.cpp#L25
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/misc.cpp#L245
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/misc.cpp#L272


## interactivity/win32/window.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/window.cpp#L129
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/window.cpp#L531
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/window.cpp#L638


## host/readDataDirect.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataDirect.cpp#L74
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataDirect.cpp#L77
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataDirect.cpp#L181


## server/ProcessList.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ProcessList.cpp#L36
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ProcessList.cpp#L88
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ProcessList.cpp#L91


## host/selectionInput.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/selectionInput.cpp#L25
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/selectionInput.cpp#L271
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/selectionInput.cpp#L336


## tsf/TfEditSession.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/tsf/TfEditSession.cpp#L70
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/tsf/TfEditSession.cpp#L693
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/tsf/TfEditSession.cpp#L1030


## server/ObjectHandle.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ObjectHandle.cpp#L228
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ObjectHandle.cpp#L242
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/ObjectHandle.cpp#L267


## host/CommandListPopup.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/CommandListPopup.cpp#L58
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/CommandListPopup.cpp#L244


## interactivity/win32/windowio.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/windowio.cpp#L69
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/win32/windowio.cpp#L992


## host/conimeinfo.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/conimeinfo.cpp#L338
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/conimeinfo.cpp#L418


## host/input.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/input.cpp#L199
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/input.cpp#L276


## host/consoleInformation.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/consoleInformation.cpp#L72
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/consoleInformation.cpp#L84


## host/readDataRaw.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/readDataRaw.cpp#L77-L79


## tsf/TfDispAttr.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/tsf/TfDispAttr.cpp#L102
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/tsf/TfDispAttr.cpp#L115


## host/inputReadHandleData.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/inputReadHandleData.cpp#L64


## host/directio.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/directio.cpp#L196
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/directio.cpp#L239


## host/ConsoleArguments.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/ConsoleArguments.cpp#L351
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/ConsoleArguments.cpp#L552


## propsheet/registry.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/registry.cpp#L309
https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/registry.cpp#L781


## server/WaitBlock.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/WaitBlock.cpp#L243


## host/writeData.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/writeData.cpp#L122


## propsheet/misc.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/propsheet/misc.cpp#L470


## interactivity/base/ServiceLocator.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/interactivity/base/ServiceLocator.cpp#L38


## host/stream.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/stream.cpp#L76


## host/dbcs.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/host/dbcs.cpp#L95


## server/IoSorter.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/server/IoSorter.cpp#L91


## types/sgrStack.cpp

https://github.com/microsoft/terminal/blob/ab04067e49a9cf9eee36335d46eefbe13db72050/src/types/sgrStack.cpp#L95