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.
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
Console.Unix: also reset terminal state when process terminates due to an unhandled exception. #111272
Console.Unix: also reset terminal state when process terminates due to an unhandled exception. #111272
Changes from 1 commit
7bb253a
24f175f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think that we should do that before the
s_initialized
is set to true (so settings_initialized
totrue
is the last thing that is part of the initialization logic)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 put it here intentionally because we won't start modifying the terminal until we've reached this point.
At this location we're sure to only add the delegate once.
I'm fine with moving it higher up, though this location should also be fine.
@adamsitnik can you confirm you'd still like me to move this higher up?
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.
We won't start modifying because there is a lock, but in theory once the flag is set to true some other thread can assume everything is initialized and it can be used.
runtime/src/libraries/System.Console/src/System/ConsolePal.Unix.cs
Lines 868 to 874 in 5abf582
I just like to have all initialization flags set to true when all the initialization logic is finished. I won't block the PR without it, but I think that in the future somebody can add some new initialization logic after your new logic and then we are going to be in trouble if we miss that in a code review.
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.
Does it mean that registering after
s_initialized
is set increases chances that the app will terminate without resetting the terminal?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.
Based on the logic for
AppDomain.CurrentDomain
I believe it's possible to be so (it seems to be non-trivial and can take some time, so in meantime something can use the console and then somehow crash the app).runtime/src/libraries/System.Private.CoreLib/src/System/AppDomain.cs
Lines 31 to 43 in 5abf582
But the chances are very low.
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.
BTW this comment made me realize that simplest "Hello World" app size after trimming may grow with this change. I am still not against it, just something to keep in mind.
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 agree that the chances are low, but this ordering is needlessly increasing them.
This is true for a lot of PRs.
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 know, but in case of Hello World there are some benchmarks that some people look at when comparing tech stacks. I just wanted to point it out since IIRC we may be having some automation that tracks such regressions. So then the person looking at it will find my comment and close it as "by design".
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.
fyi, I explored what the implementation would need to implement it in a native signal handler. The challenge is that runtime will reset to the default SIGABRT handler (in
PROCAbort
by callingSEHCleanupSignals
) and a handler that was added later forConsole
that chains back to the runtime handler is not called.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.
@tmds big thanks for explaining why we have not relied on SIGABRT!
Check failure on line 121 in src/native/libs/System.Native/pal_console_wasi.c
Azure Pipelines / runtime (Build wasi-wasm linux Release WasmBuildTests)
src/native/libs/System.Native/pal_console_wasi.c#L121
Check failure on line 121 in src/native/libs/System.Native/pal_console_wasi.c
Azure Pipelines / runtime (Build wasi-wasm linux Release LibraryTests_Smoke)
src/native/libs/System.Native/pal_console_wasi.c#L121
Check failure on line 121 in src/native/libs/System.Native/pal_console_wasi.c
Azure Pipelines / runtime
src/native/libs/System.Native/pal_console_wasi.c#L121
Check failure on line 121 in src/native/libs/System.Native/pal_console_wasi.c
Azure Pipelines / runtime
src/native/libs/System.Native/pal_console_wasi.c#L121