Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intentionally leak our Application, so that we DON'T crash on exit #5629

Merged
merged 1 commit into from
Apr 30, 2020

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Apr 28, 2020

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

@zadjii-msft
Copy link
Member Author

@DHowett-MSFT should we selfhost this first as a sanity check? this seems like it can't be right, but hey, it works on my machine

@DHowett-MSFT
Copy link
Contributor

Sure, I'll spin a selfghost build.

@DHowett-MSFT
Copy link
Contributor

It doesn't seem to be causing issues on Release for me.

@zadjii-msft
Copy link
Member Author

It doesn't seem to be causing issues on Release for me.

Good enough for me ¯\_(ツ)_/¯

@zadjii-msft zadjii-msft added Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal. labels Apr 30, 2020
@ghost ghost requested review from miniksa, carlos-zamora and leonMSFT April 30, 2020 13:27
@zadjii-msft zadjii-msft merged commit b6a21de into master Apr 30, 2020
@zadjii-msft zadjii-msft deleted the dev/migrie/b/leak-the-memory-to-NOT-crash branch April 30, 2020 19:36
@ghost
Copy link

ghost commented May 5, 2020

🎉Windows Terminal Release Candidate v0.11.1251.0 (1.0rc1) has been released which incorporates this pull request.:tada:

Handy links:

@zadjii-msft zadjii-msft mentioned this pull request Mar 10, 2023
9 tasks
DHowett pushed a commit that referenced this pull request May 26, 2023
…5451)

This is a resurrection of #5629. As it so happens, this crash-on-exit
was _not_ specific to my laptop. It's a bug in the XAML platform
somewhere, only on Windows 10.

In #14843, we moved this leak into `becomeMonarch`. Turns out, we don't
just need this leak for the monarch process, but for all of them.

It's not a real "leak", because ultimately, our `App` lives for the
entire lifetime of our process, and then gets cleaned up when we do. But
`dtor`ing the `App` - that's apparently a no-no.

Was originally in #15424, but I'm pulling it out for a super-hotfix
release.


Closes #15410

MSFT:35761869 looks like it was closed as no repro many moons ago. This
should close out our hits there (firmly **40% of the crashes we've
gotten on 1.18**)
DHowett pushed a commit that referenced this pull request May 26, 2023
…5451)

This is a resurrection of #5629. As it so happens, this crash-on-exit
was _not_ specific to my laptop. It's a bug in the XAML platform
somewhere, only on Windows 10.

In #14843, we moved this leak into `becomeMonarch`. Turns out, we don't
just need this leak for the monarch process, but for all of them.

It's not a real "leak", because ultimately, our `App` lives for the
entire lifetime of our process, and then gets cleaned up when we do. But
`dtor`ing the `App` - that's apparently a no-no.

Was originally in #15424, but I'm pulling it out for a super-hotfix
release.

Closes #15410

MSFT:35761869 looks like it was closed as no repro many moons ago. This
should close out our hits there (firmly **40% of the crashes we've
gotten on 1.18**)

(cherry picked from commit aa8ed8c)
Service-Card-Id: 89332890
Service-Version: 1.18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants