microsoft / microsoft/terminal

Windows Server 2025: Windows Terminal: Crash in OpenConsole.exe (0xc0000094, division by zero) causes programs to fail with 0xC0000142. How to detect and work around this Windows Terminal version?

Open
#18,209 7 comments 0 reactions 0 assignees View on GitHub
Issue-Bug Needs-Tag-Fix Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.18.2401

### Windows build number

10.0.26100.2314

### Other Software

Bitvise SSH Server 9.39 installer
Bitvise SSH Client 9.39 installer

### Steps to reproduce

This problem is frequently observed by users of Bitvise software who attempt to install on Windows Server 2025 before the Windows Terminal has updated to a more recent version. The problem has also been reported with Windows 11.

To reproduce:

Issue version 1:
- Ensure the installed Windows Terminal version is the one that ships with the OS (e.g. version 1.18 for Windows Server 2025)
- Download Bitvise SSH Server installer: https://bitvise.com/ssh-server-download
- Open Command Prompt in Windows Terminal with administrative rights
- Run "BvSshServer-Inst.exe -?" for command-line help
- Observe that the Windows Terminal window closes abruptly
- Observe that events from "Application Error" and "Windows Error Reporting" appear in the Windows Event Log
- The error events show OpenConsole.exe crashing with exception code 0xc0000094 (integer division by zero)

Issue version 2:
- Run Bitvise SSH Server installer from Windows File Explorer
- The installer is a console application with graphical UI. Windows Terminal window opens in background for the console output
- Attempt to install the SSH Server
- Installation fails when the installer tries to run BvSshServer.exe to register the Windows service
- Error code from BvSshServer.exe is 0xC0000142, corresponding to DLL initialization issue
- Observe that events from "Application Error" and "Windows Error Reporting" appear in the Windows Event Log
- The error events show OpenConsole.exe crashing with exception code 0xc0000094 (integer division by zero)

Both problems appear to resolve themselves after Windows Terminal auto-updates to a newer version. This auto-update appears to happen unpredictably in the background, without notice to the user that something has changed.

After Windows Terminal auto-updates to 1.21.2911, the installers work - the OpenConsole crash no longer occurs.

Since Windows Server 2025 comes bundled with Windows Terminal 1.18, and the Windows Terminal version frequently does NOT update before the user attempts to install Bitvise software:
- We need a way to detect the application is running under Windows Terminal
- We need a way to detect the version of Windows Terminal, so that issues in the version that ships with the OS can be avoided

### Minimal Reproducible Example

We have identified the cause of the crash in Windows Terminal 1.18 and wrote a trivial C++ program which reproduces it reliably:

[TestConsoleBuf.txt](https://github.com/user-attachments/files/17792233/TestConsoleBuf.txt)

Conditions for the crash are set up if a program calls `SetConsoleScreenBufferSize` to enlarge the screen buffer height. The crash occurs when another program is run in the same terminal window.

This is fixed in newer Windows Terminal versions, but Windows Terminal 1.18 ships with Windows Server 2025. It is not necessarily updated before the user tries to run software in it.

It would be useful to have a documented mechanism to:
(A) detect that the program runs under Windows Terminal, and
(B) detect the Windows Terminal version.

In the absence of such a feature, our current workaround is to detect that screen buffer height == window height, and avoid enlarging the screen buffer height in this circumstance. We assume that problems might arise if the heights are equal and become unequal.

Contributor guide

Open the contributing guide

Research direction

Start with the attached TestConsoleBuf.txt reproduction and the SetConsoleScreenBufferSize call described in the issue. Investigate how Windows Terminal versions 1.18 and 1.21 differ for this scenario, and identify an appropriate documented mechanism for detecting the host and its version. Done means the mechanism is specified and validated against the reported crash and workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.