-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Use TerminateProcess to exit early #16575
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e91fa75
this is capital-B bodgy
zadjii-msft 1ce5f13
fine
zadjii-msft ad2ad9d
clean, add comments
zadjii-msft 8b1ffb1
Use TerminateProcess
lhecker 1405749
Address feedback
lhecker 5ad7a42
Add a comment
lhecker 059ca4a
Merge remote-tracking branch 'origin/main' into dev/migrie/b/leak-the…
lhecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right place to put this. A destructor that exits the process seems bodgy indeed, but it doesn't need to be bodgy if we simply exit outside of the destructor. I'd either put this into main itself or into
HandleCommandlineArgs
, after callingWaitForWindows()
directly after the_becomeMonarch()
line. It already has a call toquick_exit
in the other branch and now this branch will have an explicitexit
. It seems we've found that there aren't any circumstances where we want a clean exit to occur. I'd simply callquick_exit
under both circumstances.Finally, I've found that this trick won't reliably work for unpackaged WT. There, the CRT will call
ExitProcess
instead ofTerminateProcess
which has similar issues. Among others, we still run into the deadlock issue withwil::unique_folder_change_reader_nothrow
. Personally, I'd callTerminateProcess
explicitly on#ifdef NDEBUG
andquick_exit
otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I had in mind: https://github.com/microsoft/terminal/compare/dev/lhecker/16575-TerminateProcess
The benefits of the larger changeset are that it also works for unpackaged WT, it avoids shutdown issues by not calling
WindowThread::ThrowAway
on Win10, it fixes theTerminateThread
call inAppHost::_HandleCommandlineArgs
(unless I misunderstood its intention and it's supposed to bePostQuitMessage
?), and it simplifies theWindowEmperor::HandleCommandlineArgs
function by unifying the two exit paths (as mentioned in my above comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm cool with that instead of this. Did you test #15410 on Windows 10 to make sure we don't regress it? If that works, then I'm inclined to say that yours is more correct and overall less bodgy (whereas this PR is more bodgy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test it the way the issue describes it specifically but I did run that code on a Windows 10 VM and it seemed fine. Thinking about it, it should work fine too, because
WindowEmperor
now doesn't get a chance anymore to go out of scope inwWinMain
which means that the destructor can't run either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Can y'all work this out so we can cut a 1.18 test build soon? :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this PR with my branch and you could review it now @DHowett.
The only thing I'm worried about is...