[PR #843] Fix #453: Setting historySize=32767 causes WindowsTerminal to hang #24347

Open
opened 2026-01-31 09:02:44 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/843

State: closed
Merged: Yes


With this change, setting the scrollback history size (number of scrollback rows) to more than about 32,000 will no longer cause Windows Terminal to hang forever.

The problem was indeed what @zadjii-msft said it might be in the bug - the history size is persisted into profiles.json as a 32-bit signed integer (well, really a JSON/JS number, but the internal data models use 32-bit ints), but was being coerced without overflow checks into 16 bits, and the bug was the overflow in question. The fix was to clamp the history size read in to a non-negative 16-bit signed integer.

I also took the liberty of adding similar overflow/underflow clamping for the initial number of rows and columns in the window.

Testing:

No doc changes made or required
Fixes #453

**Original Pull Request:** https://github.com/microsoft/terminal/pull/843 **State:** closed **Merged:** Yes --- With this change, setting the scrollback history size (number of scrollback rows) to more than about 32,000 will no longer cause Windows Terminal to hang forever. The problem was indeed what @zadjii-msft said it might be in the bug - the history size is persisted into profiles.json as a 32-bit signed integer (well, really a JSON/JS number, but the internal data models use 32-bit ints), but was being coerced without overflow checks into 16 bits, and the bug was the overflow in question. The fix was to clamp the history size read in to a non-negative 16-bit signed integer. I also took the liberty of adding similar overflow/underflow clamping for the initial number of rows and columns in the window. Testing: - manual - CI build and test passes, including new unit tests I added: https://dev.azure.com/ms/Terminal/_build/results?buildId=15717 (note: the TerminalControl changes aren't currently tested as I couldn't find any existing test scaffolding) No doc changes made or required Fixes #453
claunia added the pull-request label 2026-01-31 09:02:44 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24347