summaryrefslogtreecommitdiffstats
path: root/PC/winreg.c
diff options
context:
space:
mode:
authorTony Roberts <tony@pyxll.com>2019-02-02 17:16:42 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2019-02-02 17:16:42 (GMT)
commit4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f (patch)
tree18e9232f27d8bee1c9a8139937b69ec013a19abf /PC/winreg.c
parent2de576e16d42ce43698d384d0dd46ba6cf165424 (diff)
downloadcpython-4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f.zip
cpython-4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f.tar.gz
cpython-4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f.tar.bz2
bpo-33895: Relase GIL while calling functions that acquire Windows loader lock (GH-7789)
LoadLibrary, GetProcAddress, FreeLibrary and GetModuleHandle acquire the system loader lock. Calling these while holding the GIL will cause a deadlock on the rare occasion that another thread is detaching and needs to destroy its thread state at the same time.
Diffstat (limited to 'PC/winreg.c')
-rw-r--r--PC/winreg.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/PC/winreg.c b/PC/winreg.c
index 8ed6be4..3a6ea36 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -984,10 +984,12 @@ winreg_DeleteKeyEx_impl(PyObject *module, HKEY key,
/* Only available on 64bit platforms, so we must load it
dynamically. */
+ Py_BEGIN_ALLOW_THREADS
hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod)
pfn = (RDKEFunc)GetProcAddress(hMod,
"RegDeleteKeyExW");
+ Py_END_ALLOW_THREADS
if (!pfn) {
PyErr_SetString(PyExc_NotImplementedError,
"not implemented on this platform");
@@ -1714,10 +1716,12 @@ winreg_DisableReflectionKey_impl(PyObject *module, HKEY key)
/* Only available on 64bit platforms, so we must load it
dynamically.*/
+ Py_BEGIN_ALLOW_THREADS
hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod)
pfn = (RDRKFunc)GetProcAddress(hMod,
"RegDisableReflectionKey");
+ Py_END_ALLOW_THREADS
if (!pfn) {
PyErr_SetString(PyExc_NotImplementedError,
"not implemented on this platform");
@@ -1757,10 +1761,12 @@ winreg_EnableReflectionKey_impl(PyObject *module, HKEY key)
/* Only available on 64bit platforms, so we must load it
dynamically.*/
+ Py_BEGIN_ALLOW_THREADS
hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod)
pfn = (RERKFunc)GetProcAddress(hMod,
"RegEnableReflectionKey");
+ Py_END_ALLOW_THREADS
if (!pfn) {
PyErr_SetString(PyExc_NotImplementedError,
"not implemented on this platform");
@@ -1799,10 +1805,12 @@ winreg_QueryReflectionKey_impl(PyObject *module, HKEY key)
/* Only available on 64bit platforms, so we must load it
dynamically.*/
+ Py_BEGIN_ALLOW_THREADS
hMod = GetModuleHandleW(L"advapi32.dll");
if (hMod)
pfn = (RQRKFunc)GetProcAddress(hMod,
"RegQueryReflectionKey");
+ Py_END_ALLOW_THREADS
if (!pfn) {
PyErr_SetString(PyExc_NotImplementedError,
"not implemented on this platform");