Terminal: Terminal crashes on select text -> copy

Created on 26 Apr 2020  路  10Comments  路  Source: microsoft/terminal

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.778]
Windows Terminal
Version: 0.11.1121.0

Any other software?
Not sure about the interactions but seeing it in Terminal -> Powershell 7 tab -> linux shell in docker like docker exec -it httpd:2.4 sh. The docker/linux shell/ps7 could be unrelated but since 99% of the copy-pasting is happening there, that's what is being observed.

Steps to reproduce

It doesn't happen every the time text is copied from the terminal but does about every 20 minutes during a regular session. Killing the entire session at the most inopportune time really messes up any debug/test/dev sessions :/

Expected behavior

Text is copied to the clipboard

Actual behavior

Terminal crashes. The Window disappears and needs to be relaunched. Event Viewer has the following entry

Faulting application name: WindowsTerminal.exe, version: 0.11.2004.21001, time stamp: 0x5e9f37d1
Faulting module name: TerminalApp.dll, version: 0.11.2004.21001, time stamp: 0x5e9f3768
Exception code: 0xc0000005
Fault offset: 0x000000000000a253
Faulting process id: 0x8384
Faulting application start time: 0x01d61c007975d66b
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\TerminalApp.dll
Report Id: 26a8ddc4-fd78-4ea7-a11a-dbf7bfcc02c4
Faulting package full name: Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

terminal's settings.json

// This file was initially generated by Windows Terminal 0.11.1121.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": true,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "fontFace" : "Roboto Mono for Powerline",
            "fontSize" : 10
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [],

    // Add custom keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
    "keybindings":
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },

        // Press Ctrl+Shift+F to open the search box
        { "command": "find", "keys": "ctrl+shift+f" },

        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}
Area-User Interface Issue-Bug Needs-Tag-Fix Priority-0 Product-Terminal Severity-Crash

Most helpful comment

Hi there!

Can you please send us feedback with the Feedback Hub with this issue and paste the link here so we can more easily find your crash information on the back end?

Thanks!

image image

All 10 comments

@DHowett-MSFT This might be one of our big crash buckets, though hard to diagnose farther considering there's not a consistent repro.

I'm gonna pre-emptively throw on 1.0 to see if someone's got cycles to try and investigate, feel free to override me.

Same boat, different Exception code though.
Mostly I'm not even trying to copy or paste anything. Looking at it just makes it crash.

Hope this helps:

 Faulting application name: WindowsTerminal.exe, version: 0.11.2004.21001, time stamp: 0x5e9f37d1
 Faulting module name: TerminalControl.dll, version: 0.11.2004.21001, time stamp: 0x5e9f36e0
 Exception code: 0xc0000409
 Fault offset: 0x0000000000075c34
 Faulting process id: 0x1ee0
 Faulting application start time: 0x01d61c8932b5fe0f
 Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
 Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\TerminalControl.dll
 Report Id: ee343f9e-77cd-4f13-9fa7-225b9ebc6dae
 Faulting package full name: Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe
 Faulting package-relative application ID: App

@weust1979 If you've got a _consistent_ crash, then would you mind filing feedback using the feedback hub? That'll help get us a stack trace that we can actually investigate.

/feedback

Hi there!

Can you please send us feedback with the Feedback Hub with this issue and paste the link here so we can more easily find your crash information on the back end?

Thanks!

image image

@weust1979 If you've got a _consistent_ crash, then would you mind filing feedback using the feedback hub? That'll help get us a stack trace that we can actually investigate.

/feedback

Will do.

This is happening QUITE often with the newest release. I did reset all my settings since the profile.json changes were breaking changes.

From today, this happened purely within PS7 shell + java console, copied text via selection and then scrolled up to see something - BOOM! Gone ...

@zadjii-msft : Can you have it where the app can report the error upon failure itself? Instead of having users do a dance with the feedback hub app "Start recording" -> try -> won't crash -> repeat. It's frustrating enough that terminal crashes on copy-paste in the middle of extensive debug sessions - adding the frustrating of trying to manually record/time it in feedback hub is very primitive (and unproductive).

Faulting application name: WindowsTerminal.exe, version: 0.11.2004.21001, time stamp: 0x5e9f37d1
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.18362.752, time stamp: 0x458b530d
Exception code: 0xc000027b
Fault offset: 0x00000000007132e0
Faulting process id: 0x76a8
Faulting application start time: 0x01d61cb386636ddf
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 733fec87-8e40-4d76-89c7-858f022dbf1b
Faulting package full name: Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

_what the dang heck_

I got VS to break into an exception handler in this scenario, but the results are _unexpected_. The stack was:

```c#
TerminalApp.dll!winrt::throw_hresult(const winrt::hresult result) Line 4689 C++
TerminalApp.dll!winrt::check_hresult(const winrt::hresult result) Line 4735 C++
TerminalApp.dll!winrt::impl::consume_Windows_ApplicationModel_DataTransfer_IClipboardStatics::Flush() Line 92 C++
TerminalApp.dll!winrt::Windows::ApplicationModel::DataTransfer::Clipboard::Flush::__l2::::operator()(const winrt::Windows::ApplicationModel::DataTransfer::IClipboardStatics & f) Line 2585 C++
TerminalApp.dll!::(const winrt::Windows::ApplicationModel::DataTransfer::IClipboardStatics & f) Line 2585 C++
TerminalApp.dll!winrt::impl::factory_cache_entry::call TerminalApp.dll!winrt::impl::call_factory_cast>(winrt::Windows::ApplicationModel::DataTransfer::Clipboard::Flush::__l2:: && callback) Line 6024 C++
TerminalApp.dll!winrt::Windows::ApplicationModel::DataTransfer::Clipboard::Flush() Line 2586 C++

TerminalApp.dll!winrt::TerminalApp::implementation::TerminalPage::_CopyToClipboardHandler$_ResumeCoro$2() Line 1349 C++
[External Code]
TerminalApp.dll!winrt::resume_foreground::__l2::awaitable::await_suspend::__l2::::operator()() Line 3326 C++
TerminalApp.dll!winrt::impl::delegate>::Invoke() Line 1276 C++
[External Code]
WindowsTerminal.exe!wWinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, wchar_t * __formal, int __formal) Line 128 C++
[External Code]


which points to 
https://github.com/microsoft/terminal/blob/e358b967461f9ae20a3eef6e1487d91ed50f7205/src/cascadia/TerminalApp/TerminalPage.cpp#L1354-L1359

You'll note, this code is already in a [`try...catch`](https://user-images.githubusercontent.com/18356694/80536183-9bfe6a00-8967-11ea-9677-8cb34d4a588b.png)


These messages get logged right when the crash happens:

com\ole32\ole232\clipbrd\clipapi.cpp(2516)\ole32.dll!00007FFB71CF7AEE: (caller: 00007FFB71CF840B) ReturnHr(1) tid(507c) 800401D0 OpenClipboard Failed
Exception thrown at 0x00007FFB711D361C (KernelBase.dll) in WindowsTerminal.exe: WinRT originate error - 0x800401D0 : 'OpenClipboard Failed'.
Exception thrown at 0x00007FFB711D361C in WindowsTerminal.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000ECE89FEB60.
```

If you just continue here, then the app just chugs along on its merry way. So this can't be the _actual_ crash, right?

@ future-me: You know what, I've been trying 0.11.1151 and master, and this might magically be fixed by the #selection-locking-issue I can't find right now

Hey so other than the fact that we'll occasionally catch an exception here, I can't repro this crash locally. I couldn't get it to happen with any of the 0.11.* releases. So maybe there's something else that's going on? Something that's causing that exception to not just get caught, but tear the whole process down. Maybe it has something to do with "Call this method only when the application is in the foreground, or when a debugger is attached."? I'm out of ideas tbh.

Maybe this is specific to the 10.0.18362.752 version of Windows.UI.Xaml.dll, and simply doesn't repro on 10.0.19619.1000?

Curiously, the event viewer events posted in this thread are for three _different_ dlls - Windows.UI.Xaml, TerminalControl and TerminalApp. Maybe WUX and TerminalApp are related, but I'd bet the TerminalControl one that @weust1979 was seeing is fixed either in the latest 0.11 release or the next one.

I'm gonna unassign myself from this one for now, but we should keep an eye on it. Maybe punt for now till we get a repro, or something actionable?

On my desktop I just now updated from 0.11.1121.0 to 0.11.1191.0.
Will see how things go there.

On my work laptop I have the same version and will upgrade to 0.11.1191.0 as well.
Haven't seen crashes there, but I did make it a habit of starting tmux once I SSH'd in on a GNU/Linux jumphost server.

At home I try to avoid GNU/Linux as much as I can, and run FreeBSD.
And I think I had no issues there when running inside a tmux as well.
Running in a tmux on FreeBSD is preferable anyway since there is a nasty issue with text getting overwritten when you edit a command line. It's there, just not shown.
Different issue though.

So at my end, I no longer see those crashes. I'm not sure what exactly helped but the Terminal version I now see is is 0.11.1191.0 and I also set "copyOnSelect": false,.

I'm closing this for now since I'm not seeing it, nor do I have time to capture more debug info. IMHO, the terminal developers need to instrument the binary to automatically capture dump information and have some sort of [Send] or [Cancel] [X] remember my choice mechanism built into it. I've seen even solo developer projects have this sort of error reporting, so something reasonably staffed as Windows Terminal ought to have it too (or better).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Byloth picture Byloth  路  56Comments

Paul-Weisser picture Paul-Weisser  路  71Comments

yanglr picture yanglr  路  235Comments

NOFUNEVER picture NOFUNEVER  路  106Comments

cinnamon-msft picture cinnamon-msft  路  62Comments