diff options
| author | Tony Roberts <tony@pyxll.com> | 2019-02-02 18:16:42 +0100 | 
|---|---|---|
| committer | Steve Dower <steve.dower@microsoft.com> | 2019-02-02 09:16:42 -0800 | 
| commit | 4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f (patch) | |
| tree | 18e9232f27d8bee1c9a8139937b69ec013a19abf /Python/dynload_win.c | |
| parent | 2de576e16d42ce43698d384d0dd46ba6cf165424 (diff) | |
| download | cpython-git-4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f.tar.gz | |
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 'Python/dynload_win.c')
| -rw-r--r-- | Python/dynload_win.c | 6 | 
1 files changed, 6 insertions, 0 deletions
| diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 0fdf77f552..129e04d1b2 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -218,8 +218,10 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,          /* We use LoadLibraryEx so Windows looks for dependent DLLs              in directory of pathname first. */          /* XXX This call doesn't exist in Windows CE */ +        Py_BEGIN_ALLOW_THREADS          hDLL = LoadLibraryExW(wpathname, NULL,                                LOAD_WITH_ALTERED_SEARCH_PATH); +        Py_END_ALLOW_THREADS  #if HAVE_SXS          _Py_DeactivateActCtx(cookie);  #endif @@ -298,11 +300,15 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,                               "Module use of %.150s conflicts "                               "with this version of Python.",                               import_python); +                Py_BEGIN_ALLOW_THREADS                  FreeLibrary(hDLL); +                Py_END_ALLOW_THREADS                  return NULL;              }          } +        Py_BEGIN_ALLOW_THREADS          p = GetProcAddress(hDLL, funcname); +        Py_END_ALLOW_THREADS      }      return p; | 
