gh-104530: Use native Win32 condition variables#104531
Conversation
|
I'll defer to @zooba and other Windows experts on this one. |
|
I definitely want the fixes in this PR, even if we don't change the default setting for CVs. My main concern is destabilising things - @encukou has just spent days tracking down a Windows deadlock, and I'd hate to give him a whole lot of new ones ;) But let's see what the buildbots say |
Eh, I think there are more deadlocks waiting to be solved even without this PR. |
|
Alright, let's YOLO it 😆 Easy enough to change the setting to disable later on if it turns out to be trouble, but alphas are definitely the time to turn it on. |
Update Python to using native Win32 condition variable support, by setting
_PY_EMULATED_WIN_CVto0.A small fix to
PyCOND_TIMEDWAIT()was required to correctly report condition variable timeouts.After doing this, I found that
_listdir_windows_no_opendir()was crashing becausePy_END_ALLOW_THREADSis overwriting Win32's GLE and the error codeERROR_NO_MORE_FILESfromFindNextFileW()was being wiped out:I debugged this (using iDNA/TTD) and found that
SleepConditionVariableSRW()was clearing the Win32 GLE inPy_END_ALLOW_THREADS:I have fixed this by adding code to
PyEval_RestoreThreadto save and restore the Win32 GLE, and removing the code inPyThread_tss_get()andPyThread_get_key_value()that does the same (as it's no longer required).cc: @ericsnowcurrently