The system detected an overrun of a stack-based buffer in this application #10813

Closed
opened 2026-01-31 02:30:59 +00:00 by claunia · 11 comments
Owner

Originally created by @unavaliabl3 on GitHub (Sep 28, 2020).

Environment

Windows build number:  19041.388
Windows Terminal version (if applicable): 1.3.2651.0

Steps to reproduce

  • on Windows PowerShell execute cat <a big file: lager than 2MB>, using vim to edit the big file, list files in the directory, use any terminal program to deal with big files will cause error The system detected an overrun of a stack-based buffer in this application

  • on WSL execute htop,top,cat <a big file>, using any programs to process file larger than 2MB, use resources intensive programs such as MySQL server will cause error The system detected an overrun of a stack-based buffer in this application

  • on cmd, PowerShell core, git bash, etc. is the same

the error only occurs when running shell on Windows Terminal , not the programs them self.

screenshots

image
image
image
image
image
image

PS

The shell and programs are still running after Windows Terminal crashed.

Originally created by @unavaliabl3 on GitHub (Sep 28, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 19041.388 Windows Terminal version (if applicable): 1.3.2651.0 ``` # Steps to reproduce - on Windows PowerShell execute ```cat <a big file: lager than 2MB>```, using vim to edit the big file, list files in the directory, use any terminal program to deal with big files will cause error ```The system detected an overrun of a stack-based buffer in this application ``` - on WSL execute ```htop```,```top```,```cat <a big file>```, using any programs to process file larger than 2MB, use resources intensive programs such as MySQL server will cause error ```The system detected an overrun of a stack-based buffer in this application ``` - on cmd, PowerShell core, git bash, etc. is the same the error only occurs when running shell on Windows Terminal , not the programs them self. # screenshots ![image](https://user-images.githubusercontent.com/52642831/94420094-3c2a1a80-01b6-11eb-843e-834e170e564f.png) ![image](https://user-images.githubusercontent.com/52642831/94420122-477d4600-01b6-11eb-9f44-5a1c76dc5216.png) ![image](https://user-images.githubusercontent.com/52642831/94420126-49470980-01b6-11eb-8d6a-8bd6cb99fe62.png) ![image](https://user-images.githubusercontent.com/52642831/94420382-a8a51980-01b6-11eb-8c73-773d0bf16f89.png) ![image](https://user-images.githubusercontent.com/52642831/94420502-d4280400-01b6-11eb-8057-0a21cf73c0fd.png) ![image](https://user-images.githubusercontent.com/52642831/94420499-d38f6d80-01b6-11eb-938b-ae8828ed4c75.png) # PS The shell and programs are still running after Windows Terminal crashed.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 28, 2020):

I hit something similar on 2020-09-25. Windows Terminal Preview 1.4.2652.0 on Windows 10 build 19041.508 crashed several times with exception code 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) when I was trying to use "git log". There were no message boxes but the reliability history and the Application event log show this code. I have not been able to reproduce the error later.

@KalleOlaviNiemitalo commented on GitHub (Sep 28, 2020): I hit something similar on 2020-09-25. Windows Terminal Preview 1.4.2652.0 on Windows 10 build 19041.508 crashed several times with exception code 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) when I was trying to use "git log". There were no message boxes but the reliability history and the Application event log show this code. I have not been able to reproduce the error later.
Author
Owner

@unavaliabl3 commented on GitHub (Sep 29, 2020):

The error could temporarily disappear after reboot the computer or logout and login, however, after a period of time, I can still reproduce the error. From Windows Terminal beta to 1.3.2651.0, this is the first time I get those errors. Windows Terminal Preview 1.4.2652.0 crashes on my computer too.

@unavaliabl3 commented on GitHub (Sep 29, 2020): The error could temporarily disappear after reboot the computer or logout and login, however, after a period of time, I can still reproduce the error. From Windows Terminal beta to 1.3.2651.0, this is the first time I get those errors. Windows Terminal Preview 1.4.2652.0 crashes on my computer too.
Author
Owner

@DHowett commented on GitHub (Sep 29, 2020):

I can't reproduce this. Can one of you use task manager to capture a dump file of Terminal when that dialog pops up?

@DHowett commented on GitHub (Sep 29, 2020): I can't reproduce this. Can one of you use task manager to capture a dump file of Terminal when that dialog pops up?
Author
Owner

@unavaliabl3 commented on GitHub (Sep 30, 2020):

WindowsTerminal.dmp.zip

@unavaliabl3 commented on GitHub (Sep 30, 2020): [WindowsTerminal.dmp.zip](https://github.com/rekaerst/rekaerst.github.io/raw/master/WindowsTerminal.zip)
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020):

@rekaerst's dump file has Windows_UI_Xaml!CXamlIslandRoot::OnIslandPointerWheelChanged + 0x12 in the call stack of the thread that called KERNELBASE!RaiseFailFastException. I am pretty sure I was not using the mouse wheel when Windows Terminal Preview crashed. But if the bug is in rendering, then it could crash in both situations anyway.

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020): @rekaerst's dump file has `Windows_UI_Xaml!CXamlIslandRoot::OnIslandPointerWheelChanged + 0x12` in the call stack of the thread that called `KERNELBASE!RaiseFailFastException`. I am pretty sure I was not using the mouse wheel when Windows Terminal Preview crashed. But if the bug is in rendering, then it could crash in both situations anyway.
Author
Owner

@unavaliabl3 commented on GitHub (Sep 30, 2020):

I was not using a mouse when it crashed too. I was just running cat some_text_file command.

@unavaliabl3 commented on GitHub (Sep 30, 2020): I was not using a mouse when it crashed too. I was just running cat some_text_file command.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020):

Apparently, WilFailFast uses STATUS_STACK_BUFFER_OVERRUN even if the error is not a buffer overrun. The instructions immediately before the return address TerminalControl!DllGetActivationFactory+0x27a3c set R8 = "E:\BA\127\s\src\buffer\out\textBuffer.cpp" and EDX = 280, so I think it blew up in TextBuffer::_PrepareForDoubleByteSequence here: https://github.com/microsoft/terminal/blob/d4614bf04176cc57cd9b1ee4acace8126e76450d/src/buffer/out/textBuffer.cpp#L278-L280

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020): Apparently, [`WilFailFast` uses `STATUS_STACK_BUFFER_OVERRUN`](https://github.com/microsoft/wil/blob/b74575e9feb6477c52208fbc60557ad22f8bf42b/include/wil/result_macros.h#L3599) even if the error is not a buffer overrun. The instructions immediately before the return address `TerminalControl!DllGetActivationFactory+0x27a3c` set R8 = "E:\BA\127\s\src\buffer\out\textBuffer.cpp" and EDX = 280, so I think it blew up in `TextBuffer::_PrepareForDoubleByteSequence` here: <https://github.com/microsoft/terminal/blob/d4614bf04176cc57cd9b1ee4acace8126e76450d/src/buffer/out/textBuffer.cpp#L278-L280>
Author
Owner

@DHowett commented on GitHub (Sep 30, 2020):

So, this is interesting! This dump is the same as in #4907. We've tried to tackle this issue before, but not quite gotten there. It seems that there's some buffer corruption where a DBCS character gets split and the trailing half gets duplicated (by a function that isn't checking its legality), which then explodes when it hits this function (Reflow) that does check.

We usually only see it during resize, which includes mouse wheel scrolling.

@KalleOlaviNiemitalo I'll keep this open to see if you can produce a dump that's different?

Symbols for 1.4.2652

@DHowett commented on GitHub (Sep 30, 2020): So, this is interesting! This dump is the same as in #4907. We've tried to tackle this issue before, but not quite gotten there. It seems that there's some buffer corruption where a DBCS character gets split and the trailing half gets duplicated (by a function that _isn't_ checking its legality), which then explodes when it hits this function (Reflow) that does check. We usually only see it during resize, which includes mouse wheel scrolling. @KalleOlaviNiemitalo I'll keep this open to see if you can produce a dump that's different? [Symbols for 1.4.2652](https://terminalnuget.blob.core.windows.net/packages/CascadiaPackage_1.4.2652.0_x64.appxsym)
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020):

OK, I added a Registry key as instructed in Collecting User-Mode Dumps, so that I'll get a dump if WindowsTerminal.exe crashes again.

@KalleOlaviNiemitalo commented on GitHub (Sep 30, 2020): OK, I added a Registry key as instructed in [Collecting User-Mode Dumps](https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps), so that I'll get a dump if `WindowsTerminal.exe` crashes again.
Author
Owner

@DHowett commented on GitHub (Oct 1, 2020):

Thanks!

@DHowett commented on GitHub (Oct 1, 2020): Thanks!
Author
Owner

@ghost commented on GitHub (Oct 5, 2020):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Oct 5, 2020): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10813