-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add hybrid/cooperate suspend runtime support on Windows. #14101
Add hybrid/cooperate suspend runtime support on Windows. #14101
Conversation
2863c35
to
ebcddce
Compare
ebcddce
to
0ede99d
Compare
Nice overall, just nit picking. |
First run all Windows configs have pass using default preemtive suspend. Next round will be hybrid suspend + review feedback. |
8c855fc
to
98a012b
Compare
Now just to add four or eight more CI lanes? :) |
Again very good, I just nit-picky. |
First run of hybrid suspend on CI for all Windows configuration is done! Windows x64, all CI test pass on hybrid suspend. Windows x64 FullAOT, only one failing test case, error in finalizer-exit: finalizer-exit.exe =============== EOF =============== Windows i386, 3 failures, all looks related to the same issue: MonoTests.runtime.thread-suspend-suspended.exe Cannot transition thread 000001A8 from SELF_SUSPENDED with REQUEST_PULSE |
10045aa
to
9a89cf9
Compare
Run with cooperate suspend on CI, all test pass. |
Analyzed failure in thread-suspend-suspended.exe on 32-bit Windows and the identified problem, Cannot transition thread 000001A8 from SELF_SUSPENDED with REQUEST_PULSE, could happened in the following scenarion (emulated in debugger).
If it fails due to that check stw will move over to pulse resume the thread but since it is already self suspend, it will hit the assert. The fix is to not do the wow64 critical check, mono_threads_platform_in_critical_region, if thread is not preemptive suspended. This is needed since the call to GetThreadContext is not guaranteed to get a valid context on a running thread. |
Run with hybrid suspend on CI, all Windows test lanes pass. |
Under hybrid suspend a thread can be cooperative suspended but still checked for a platform critical region under wow64. Since thread is not preemptive suspended we can't reliably call GetThreadContext and doing so could also (even correctly) return a context flagged as critical triggering an assert in stw for cooperative suspended threads.
a1452f9
to
0d39006
Compare
@monojenkins rebuild failed |
Adding initial support for hybrid and cooperate suspend on Windows 32/64-bit platforms.
Fixes/adjustments needed in several areas:
Implementation/emulation of gcc's __builtin_unwind_init on MSVC needed by copy_stack_data function.
All wait methods have been extended with a cooperative alternative + handling interrupt under hybrid/cooperative suspend.
Methods that handles IO abort interruption on Windows (file, socket) have been updated to handle interrupt under hybrid/cooperative suspend.
Moved Windows implementations into w32handle.c instead of #ifdef on call site.
Reduced number of GC safe transition in a couple of Win32 file IO methods.
Added restore logic to Win32 last error when exiting GC safe mode. This is needed since we have code that depends on GetLastError that could be clobbered if exiting GC safe mode enter a wait. Also added last error restore logic to uninstall interrupt handler since it is commonly used right after exiting GC safe mode.