microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.56k stars 8.32k forks source link

Multiple 'Settings' entries on title bar context menu. Crashes Terminal. #16211

Closed strangebit closed 1 year ago

strangebit commented 1 year ago

Windows Terminal version

1.18.2822.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

Not sure what is triggering it unfortunately.

Expected Behavior

No response

Actual Behavior

I've noticed that sometimes, after using Terminal for some time, the right-click context menu on the titlebar ends up getting multiple Settings entries. When I click on one of them, Terminal crashes. When there's only one it doesn't crash; it opens the Settings panel as it should.

See the video below. Again this is after using Terminal for some time, opening and closing windows, etc. I don't know how to reproduce the bug consistently.

https://github.com/microsoft/terminal/assets/11712728/4e8e324e-8934-42c0-8d48-b73f488d32fd

I've seen it before with as many as six of these Settings entries.

The crash in the above video corresponds to this event (if it helps):

Faulting application name: WindowsTerminal.exe, version: 1.18.2310.9002, time stamp: 0x65248b0f
Faulting module name: TerminalApp.dll, version: 1.18.2310.9002, time stamp: 0x65248aa8
Exception code: 0xc0000005
Fault offset: 0x0000000000050c6a
Faulting process ID: 0x4d8c
Faulting application start time: 0x01da047ff2360b38
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.18.2822.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.18.2822.0_x64__8wekyb3d8bbwe\TerminalApp.dll
Report ID: 4ed86fa0-563b-4b67-bb0e-de7b5ea21887
Faulting package full name: Microsoft.WindowsTerminal_1.18.2822.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

I'm not sure if it's related to my other bug report #16100.

zadjii-msft commented 1 year ago

I'm gonna guess this is also a window refrigeration bug.

I'd guess that the problem code is AppHost::_SystemMenuChangeRequested not getting called to remove the old entries before refrigeration.

Oh it definitely is. TerminalWindow only ever adds the settings entry when it gets created. AppHost however needs to clear that old entry out before we refrigerate the HWND. The old entries end up sticking around, which is why the old entries will explode the Terminal.