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

Exception 0xc0000409 in ucrtbase.dll #13193

Closed
Nazar78 opened this issue May 27, 2022 · 10 comments · Fixed by #13212
Closed

Exception 0xc0000409 in ucrtbase.dll #13193

Nazar78 opened this issue May 27, 2022 · 10 comments · Fixed by #13212
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-1 A description (P1) Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Severity-Crash Crashes are real bad news.

Comments

@Nazar78
Copy link

Nazar78 commented May 27, 2022

Windows Terminal version

1.12.10983.0

Windows build number

10.0.22000.708

Other Software

No response

Steps to reproduce

From the context menu it works, launching directly from the menu also works. But on the latest Windows 11 it doesn't work: Start -> right-click -> Windows Terminal or with Admin.

In the event viewer it's showing this:

Faulting application name: WindowsTerminal.exe, version: 1.12.2204.8003, time stamp: 0x62508e2a
Faulting module name: ucrtbase.dll, version: 10.0.22000.1, time stamp: 0x00e78ce9
Exception code: 0xc0000409
Fault offset: 0x000000000007dd7e
Faulting process id: 0x228c
Faulting application start time: 0x01d871efed6469ee
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.12.10983.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\WINDOWS\System32\ucrtbase.dll
Report Id: b77f3deb-3000-4181-9d2c-5bfb3c0e1170
Faulting package full name:
Faulting package-relative application ID:

image

Expected Behavior

The Windows Terminal should normally open.

Actual Behavior

The Windows Terminal doesn't launch.

@Nazar78 Nazar78 added the Issue-Bug It either shouldn't be doing this or needs an investigation. label May 27, 2022
@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 May 27, 2022
@abhinavsatheesh
Copy link

I seem to have the same issue with my PC.

It all started with a Windows Update to Build 22000.613

While opening by search Terminal from start menu it works.

@lhecker
Copy link
Member

lhecker commented May 30, 2022

This is likely MSFT-33471786. It occurs because we're allocating (for example) 0x1fffffffffffff30 bytes of memory.

@lhecker lhecker added Priority-1 A description (P1) Severity-Crash Crashes are real bad news. labels May 30, 2022
@lhecker
Copy link
Member

lhecker commented May 30, 2022

I have a theory why this happens but I can't reproduce the crash so I can't debug it unfortunately.
If someone has the time to spare could you please do these two things for me?

If you're uncomfortable uploading these files to GitHub, please feel free to send me them via mail to:
<my github username>@microsoft.com

  • A copy of your settings.json which you can find in this directory:
    %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState
  • A backup of your Console's registry
    • Start regedit.exe
    • Navigate to HKEY_CURRENT_USER\Console and export the Console directory as a .reg file

image

@Nazar78
Copy link
Author

Nazar78 commented May 30, 2022

@lhecker

Thank you for looking into this, here you go the files requested.
Console.reg.txt
settings.json.txt

@abhinavsatheesh
Copy link

In my Event Viewer, the crash is detailed like this

Faulting application name: WindowsTerminal.exe, version: 1.12.2204.8003, time stamp: 0x62508e2a
Faulting module name: ucrtbase.dll, version: 10.0.22000.1, time stamp: 0x00e78ce9
Exception code: 0xc0000409
Fault offset: 0x000000000007dd7e
Faulting process ID: 0x3910
Faulting application start time: 0x01d874b9caf953c6
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.12.10983.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\WINDOWS\System32\ucrtbase.dll
Report ID: 30a1bc3f-f972-455b-b2fb-f234abbcbc57
Faulting package full name:
Faulting package-relative application ID:

@ghost ghost added the In-PR This issue has a related PR label May 31, 2022
@ghost ghost closed this as completed in #13212 Jun 1, 2022
@ghost ghost added 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 Jun 1, 2022
ghost pushed a commit that referenced this issue Jun 1, 2022
MSFT-33471786 is one of the most common crashes we have right now.
Memory dumps suggest that `VtEngine::UpdateViewport` is called with a rectangle
like `(0, 46, 119, 29)` (left, top, right, bottom), which is a rectangle of
negative height. When the `_invalidMap` is resized the negative size gets
turned into a very large unsigned integer, which results in an OOM exception,
crashing OpenConsole.

`VtEngine::UpdateViewport` is called by `Renderer::_CheckViewportAndScroll`
which holds a (cached) old and a new viewport. The old viewport was
`(0, 46, 119, 75)` which is exceedingly similar to the invalid, new viewport.
It's bottom coordinate is also coincidentally larger by exactly 46 (top).

The viewport comes from the `SCREEN_INFORMATION` class whose `SetViewport`
function was highly suspicious as it has a branch which updates the bottom
to be the buffer height, but leaves the top unmodified.

`SCREEN_INFORMATION::SetViewport` is called by `SetConsoleWindowInfo` which
processes user-provided data. A repro of the crash can be constructed with:
```
SMALL_RECT rect{0, 46, 119, 75};
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &rect);
```

Closes #13193
Closes MSFT-33471786

## Validation Steps Performed
Ensured the following code doesn't crash when run under Windows Terminal:
```
SMALL_RECT rect{0, 46, 119, 75};
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &rect);
```
DHowett pushed a commit that referenced this issue Jun 30, 2022
MSFT-33471786 is one of the most common crashes we have right now.
Memory dumps suggest that `VtEngine::UpdateViewport` is called with a rectangle
like `(0, 46, 119, 29)` (left, top, right, bottom), which is a rectangle of
negative height. When the `_invalidMap` is resized the negative size gets
turned into a very large unsigned integer, which results in an OOM exception,
crashing OpenConsole.

`VtEngine::UpdateViewport` is called by `Renderer::_CheckViewportAndScroll`
which holds a (cached) old and a new viewport. The old viewport was
`(0, 46, 119, 75)` which is exceedingly similar to the invalid, new viewport.
It's bottom coordinate is also coincidentally larger by exactly 46 (top).

The viewport comes from the `SCREEN_INFORMATION` class whose `SetViewport`
function was highly suspicious as it has a branch which updates the bottom
to be the buffer height, but leaves the top unmodified.

`SCREEN_INFORMATION::SetViewport` is called by `SetConsoleWindowInfo` which
processes user-provided data. A repro of the crash can be constructed with:
```
SMALL_RECT rect{0, 46, 119, 75};
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &rect);
```

Closes #13193
Closes MSFT-33471786

## Validation Steps Performed
Ensured the following code doesn't crash when run under Windows Terminal:
```
SMALL_RECT rect{0, 46, 119, 75};
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &rect);
```

(cherry picked from commit 7dbe741)
Service-Card-Id: 82642053
Service-Version: 1.14
@ghost
Copy link

ghost commented Jul 6, 2022

🎉This issue was addressed in #13212, which has now been successfully released as Windows Terminal v1.14.186.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 6, 2022

🎉This issue was addressed in #13212, which has now been successfully released as Windows Terminal Preview v1.15.186.:tada:

Handy links:

@abhinavsatheesh
Copy link

Thanks a lot! It is now working

@H1-N1
Copy link

H1-N1 commented Mar 17, 2024

doesn't work
i have the lastes update os and terminal
[process exited with code 5 (0x00000005)]

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-1 A description (P1) 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
Development

Successfully merging a pull request may close this issue.

5 participants