[PR #5629] [MERGED] Intentionally leak our Application, so that we DON'T crash on exit #26397

Open
opened 2026-01-31 09:15:49 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5629
Author: @zadjii-msft
Created: 4/28/2020
Status: Merged
Merged: 4/30/2020
Merged by: @zadjii-msft

Base: masterHead: dev/migrie/b/leak-the-memory-to-NOT-crash


📝 Commits (1)

📊 Changes

1 file changed (+18 additions, -0 deletions)

View changed files

📝 src/cascadia/WindowsTerminal/AppHost.cpp (+18 -0)

📄 Description

We've got a weird crash that happens terribly inconsistently, but pretty
readily on migrie's laptop, only in Debug mode. Apparently, there's some
weird ref-counting magic that goes on during teardown, and our
Application doesn't get closed quite right, which can cause us to crash
into the debugger. This of course, only happens on exit, and happens
somewhere in the ...XamlHost.dll code.

Crazily, if we manually leak the Application here, then the crash
doesn't happen. This doesn't matter, because we really want the
Application to live for the entire lifetime of the process, so the only
time when this object would actually need to get cleaned up is during
exit
. So we can safely leak this Application object, and have it just
get cleaned up normally when our process exits.

  • I discussed this with @DHowett-MSFT and we both agree this is mental
  • I'm pretty sure there's not an actual bug on our repo for this
  • I verified on my machine where I can crash the terminal 100% of the time on exit in debug, this fixes it
  • I verified that it doesn't introduce a new crash in Release on my machine

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5629 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/28/2020 **Status:** ✅ Merged **Merged:** 4/30/2020 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `master` ← **Head:** `dev/migrie/b/leak-the-memory-to-NOT-crash` --- ### 📝 Commits (1) - [`0c72f87`](https://github.com/microsoft/terminal/commit/0c72f8748bfb1bb5b4982c32bf5187295472ba0a) Well this is mental ### 📊 Changes **1 file changed** (+18 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/WindowsTerminal/AppHost.cpp` (+18 -0) </details> ### 📄 Description We've got a weird crash that happens terribly inconsistently, but pretty readily on migrie's laptop, only in Debug mode. Apparently, there's some weird ref-counting magic that goes on during teardown, and our Application doesn't get closed quite right, which can cause us to crash into the debugger. This of course, only happens on exit, and happens somewhere in the `...XamlHost.dll` code. Crazily, if we _manually leak the `Application`_ here, then the crash doesn't happen. This doesn't matter, because we really want the Application to live for _the entire lifetime of the process_, so the only time when this object would actually need to get cleaned up is _during exit_. So we can safely leak this `Application` object, and have it just get cleaned up normally when our process exits. * [x] I discussed this with @DHowett-MSFT and we both agree this is mental * [x] I'm pretty sure there's not an actual bug on our repo for this * [x] I verified on my machine where I can crash the terminal 100% of the time on exit in debug, this fixes it * [x] I verified that it doesn't introduce a _new_ crash in Release on my machine --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:15:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26397