terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Windows Terminal crashes when copying text to clipboard

Open Eli-Zaretskii opened this issue 3 months ago • 17 comments

Windows Terminal version

1.22.12111.0

Windows build number

10.0.26100.4946

Other Software

No response

Steps to reproduce

Mark multiple lines of text in cmd window with the mouse. Then press Enter. Instead of copying to clipboard and removing the white background (indicating the marked text), Windows Terminal closes all of its windows. In the Event Viewer I see the following error report:

Log Name: Application Source: Application Error Date: 25/08/2025 16:42:24 Event ID: 1000 Task Category: Application Crashing Events Level: Error Keywords:
User: ELIZ-PC\EliZ Computer: EliZ-PC Description: Faulting application name: WindowsTerminal.exe, version: 1.22.2507.30001, time stamp: 0x688a554b Faulting module name: Windows.UI.Xaml.dll, version: 10.0.26100.4946, time stamp: 0x4374ba0f Exception code: 0xc000027b Fault offset: 0x0000000000903d13 Faulting process id: 0xA80 Faulting application start time: 0x1DC15C511C1B9CE Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.22.12111.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll Report Id: cdcc3dbd-cbe4-4798-bd67-4c1c7229dfbd Faulting package full name: Microsoft.WindowsTerminal_1.22.12111.0_x64__8wekyb3d8bbwe Faulting package-relative application ID: App Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application Error" Guid="{a0e9b465-b939-57d7-b27d-95d8e925ff57}" /> <EventID>1000</EventID> <Version>0</Version> <Level>2</Level> <Task>100</Task> <Opcode>0</Opcode> <Keywords>0x8000000000000000</Keywords> <TimeCreated SystemTime="2025-08-25T13:42:24.5682337Z" /> <EventRecordID>34107</EventRecordID> <Correlation /> <Execution ProcessID="9700" ThreadID="18948" /> <Channel>Application</Channel> <Computer>EliZ-PC</Computer> <Security UserID="S-1-5-21-3399388249-705443938-360606816-1001" /> </System> <EventData> <Data Name="AppName">WindowsTerminal.exe</Data> <Data Name="AppVersion">1.22.2507.30001</Data> <Data Name="AppTimeStamp">688a554b</Data> <Data Name="ModuleName">Windows.UI.Xaml.dll</Data> <Data Name="ModuleVersion">10.0.26100.4946</Data> <Data Name="ModuleTimeStamp">4374ba0f</Data> <Data Name="ExceptionCode">c000027b</Data> <Data Name="FaultingOffset">0000000000903d13</Data> <Data Name="ProcessId">0xa80</Data> <Data Name="ProcessCreationTime">0x1dc15c511c1b9ce</Data> <Data Name="AppPath">C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.22.12111.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe</Data> <Data Name="ModulePath">C:\Windows\System32\Windows.UI.Xaml.dll</Data> <Data Name="IntegratorReportId">cdcc3dbd-cbe4-4798-bd67-4c1c7229dfbd</Data> <Data Name="PackageFullName">Microsoft.WindowsTerminal_1.22.12111.0_x64__8wekyb3d8bbwe</Data> <Data Name="PackageRelativeAppId">App</Data> </EventData> </Event>

Expected Behavior

I expect that the text be copied to clipboard and the Windows Terminal keeps running.

Actual Behavior

Windows Terminal crashed and closed all of its windows.

Eli-Zaretskii avatar Aug 25 '25 13:08 Eli-Zaretskii

I don't know if this is related, but when (sometimes) copying marked text to clipboard does succeed without crashing Windows Terminal, I get in the clipboard a single very long line, instead of several lines separated by newlines. This happens when I mark several screen lines and then press Enter to copy.

Eli-Zaretskii avatar Aug 25 '25 13:08 Eli-Zaretskii

Additional info: to resolve this, I tried:

  • Restarting the computer
  • Clearing the clipboard data via Settings

Nothing helped.

Eli-Zaretskii avatar Aug 25 '25 14:08 Eli-Zaretskii

I suspect that something saved by Windows Terminal between sessions keeps causing this bug even after restarts. Is there any way of clearing the data about previous session (like the screen contents) that Windows Terminal saves between sessions?

Eli-Zaretskii avatar Aug 25 '25 14:08 Eli-Zaretskii

If you don't have anything sensitive in your buffer contents, I'd love to grab a copy - we should never crash when restoring (but I am certain we have some bugs here.)

Your buffer history and state are in %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState right next to settings.json.

DHowett avatar Aug 25 '25 15:08 DHowett

(From there, you can archive/capture/delete them)

DHowett avatar Aug 25 '25 15:08 DHowett

If you don't have anything sensitive in your buffer contents, I'd love to grab a copy - we should never crash when restoring (but I am certain we have some bugs here.)

Your buffer history and state are in %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState right next to settings.json.

I can send you these buffers, tell me how to upload them. The problem is that the buffer which caused the crash isn't among them. I guess the terminal crashes before it writes it there?

The screen contents that reliably crashes the terminal is output of GDB debugging an C application, including a backtrace. I needed to copy-paste the backtrace into an email message, but the terminal would crash each time I pressed Enter after marking the text with the mouse. Is there any trick I could use to somehow capture the problematic buffer contents?

Still, some problems are visible even in those buffers: for example, the fact that screen lines are spliced together into very long lines, instead of being separated by newlines, as they look on the screen.

All this started happening just today, as far as I could remember. It was never a problem before. And even today, not every copy crashes.

Let me know how I can help you, this is very disturbing, as I'm a heavy use of the terminal (I usually have about 5 terminal windows open and used for different purposes).

Eli-Zaretskii avatar Aug 25 '25 16:08 Eli-Zaretskii

Btw, you say "crash when restoring", but the crash doesn't happen when restoring the buffer contents. It happens later, when I copy marked text. I also tried to open a new terminal window (instead of using one of the restored ones), and the same problem happened in that new window: as soon as I marked a large amount of text (a full window of of 50+ lines) with the mouse and pressed Enter, the terminal closed after about 2 sec of not responding.

So it sounds like the copy to clipboard is what triggers the crash.

Eli-Zaretskii avatar Aug 25 '25 16:08 Eli-Zaretskii

Btw, you say "crash when restoring",

Sorry, I misinterpreted this:

I suspect that something saved by Windows Terminal between sessions keeps causing this bug

Does this issue still reproduce with the new 1.23 release/?

DHowett avatar Aug 27 '25 19:08 DHowett

I will try 1.23 as soon as it is available. For now Windows Store doesn't have it available for download.

Eli-Zaretskii avatar Aug 28 '25 11:08 Eli-Zaretskii

Latest Windows update installed Windows Terminal version 1.23.12811.0, which seems not to crash in the same scenario as the previous version. So I guess this issue can be closed now. If the problem comes back, I will report again.

Thanks.

Eli-Zaretskii avatar Oct 16 '25 09:10 Eli-Zaretskii

It happened again today, with Windows Terminal version 1.23.12811.0 on MS-Windows 11 Pro version 24H2, build 26100.7171.

The Even Viewer shows the following:

Faulting application name: WindowsTerminal.exe, version: 1.23.2510.8001, time stamp: 0x68e7198d Faulting module name: Windows.UI.Xaml.dll, version: 10.0.26100.7171, time stamp: 0x2a1b749b Exception code: 0xc000027b Fault offset: 0x00000000008fc9f3 Faulting process id: 0x1AE8 Faulting application start time: 0x1DC53CC485B79DA Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.23.12811.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll Report Id: 48c53cd6-145c-46aa-b5d1-e34aeafbf4a3 Faulting package full name: Microsoft.WindowsTerminal_1.23.12811.0_x64__8wekyb3d8bbwe Faulting package-relative application ID: App

So I'm reopening this issue.

Eli-Zaretskii avatar Dec 09 '25 18:12 Eli-Zaretskii

Can you please set up automatic dump captures and then send us a dump? https://github.com/microsoft/terminal/wiki/Troubleshooting-Tips#capture-automatically You may already have a dump file in your LocalDumps folder too.

lhecker avatar Dec 09 '25 19:12 lhecker

Can you please set up automatic dump captures and then send us a dump? https://github.com/microsoft/terminal/wiki/Troubleshooting-Tips#capture-automatically You may already have a dump file in your LocalDumps folder too.

(It's CrashDumps, not LocalDumps.) Yes, I already have the dump file, so I'm uploading it now.

WindowsTerminal.exe.6888.dmp

(Interestingly, the Registry key described in the link you sent does not specify the DumpFolder key under LocalDumps...)

Eli-Zaretskii avatar Dec 10 '25 12:12 Eli-Zaretskii

Your application is crashing with an unhandled exception: 0x8007058a = ERROR_CLIPBOARD_NOT_OPEN = Thread does not have a clipboard open.

lhecker avatar Dec 10 '25 18:12 lhecker

Hmm you said you're copying text from the terminal itself and not from any UI element, right? There's only 1 place in that version of Windows Terminal which handles terminal clipboard writes and it has an early return if OpenClipboard failed: https://github.com/microsoft/terminal/blob/v1.23.12811.0/src/cascadia/TerminalControl/ControlCore.cpp#L1309-L1314

Can you spot something I can't? 😅

lhecker avatar Dec 10 '25 18:12 lhecker

Hmm you said you're copying text from the terminal itself and not from any UI element, right? There's only 1 place in that version of Windows Terminal which handles terminal clipboard writes and it has an early return if OpenClipboard failed: https://github.com/microsoft/terminal/blob/v1.23.12811.0/src/cascadia/TerminalControl/ControlCore.cpp#L1309-L1314

Can you spot something I can't? 😅

I can describe what I did: I marked some text with a mouse, then pressed Enter. Or at least I think that's what I did; I cannot be 100% sure I didn't inadvertently press something else in-between. And yes, the marked text was in the terminal's text area, or at least that's what I marked with the mouse.

Eli-Zaretskii avatar Dec 10 '25 18:12 Eli-Zaretskii

Your application is crashing with an unhandled exception: 0x8007058a = ERROR_CLIPBOARD_NOT_OPEN = Thread does not have a clipboard open.

Given that I marked text with the mouse and pressed Enter, what would cause the clipboard not be open in this scenario?

Eli-Zaretskii avatar Dec 10 '25 18:12 Eli-Zaretskii