-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Enable mono runtime to handle SIGTERM like CoreCLR #82806 #82813
Changes from all commits
c07259e
9ac0c3b
98eeadf
38b5e87
3adb5d6
bd9326b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -189,6 +189,7 @@ mono_runtime_install_handlers (void) | |||||
win32_seh_set_handler(SIGFPE, mono_sigfpe_signal_handler); | ||||||
win32_seh_set_handler(SIGILL, mono_crashing_signal_handler); | ||||||
win32_seh_set_handler(SIGSEGV, mono_sigsegv_signal_handler); | ||||||
win32_seh_set_handler(SIGTERM, mono_sigterm_signal_handler); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is going to work on Windows we also need to handle that signal in win32_seh_set_handler as well as react to the exception that will be generated and passed to seh_vectored_exception_handler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lateralusX @lambdageek Looking for further guidance on the outstanding Windows' issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On windows there is no direct mapping with "SIGTERM", the closest we have is the probably SetConsoleCtrlHandler and mapping different scenarios like done by: Line 70 in 2327a36
This is how its handled by CoreCLR: runtime/src/coreclr/vm/ceemain.cpp Line 605 in ffffc4b
So for Mono Windows handling of "SIGTERM" it probably need to setup a console ctrl handler and then react on the event as part of that handler and can't be handled through existing vectorized exception handling logic. |
||||||
if (mini_debug_options.handle_sigint) | ||||||
win32_seh_set_handler(SIGINT, mono_sigint_signal_handler); | ||||||
#endif | ||||||
|
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.
Since this is updated from a different thread without any locking, maybe we would need a read memory barrier to make sure we see updated value, especially when wait == FALSE,. There might be one hidden in the mono_coop_sem_timedwait, looks like at least sem_trywait seems to issue memory barriers, and other implementations probably do as well (like WaitForSingleObjectEx), so maybe not needed in the end, but we depend on implementation details. I guess we can leave it as is for now, just wanted to make a comment/note around potential but adding a read barrier in that code path shouldn't be too dramatic.
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 at one point, this PR had
mono_term_signaled
asvolatile
.Maybe that (or something else) is needed to ensure these lines don't reorder, causing the wrong exit code to be picked up.
This is how the exit code is set:
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 can always do acquire/release semantics on
mono_term_signaled
and we would make sure this is not reordered by compiler or CPU. Just usingvolatile
onmono_term_signaled
will only prevent compiler to reorder load/store but CPU is still free to do load/store reorder.