[issue29399] python3.dll export forwarders not resolved in all situations due to missing python3?.dll dependency and DLL search path behavior

Eryk Sun report at bugs.python.org
Thu Feb 25 13:37:02 EST 2021


Eryk Sun <eryksun at gmail.com> added the comment:

> The APIs are the same, so you can (should) LoadLibrary the one 
> that you want.

The issue is that python3.dll doesn't depend on python3x.dll in the normal way. For example, LoadLibraryExW("path/to/python3.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH) doesn't automatically load "python38.dll". But the forwarded functions depend on "python38.dll", e.g. "Py_Main (forwarded to python38.Py_Main)". The loader doesn't try to load "python38.dll" until the application tries to resolve a forwarded function such as "Py_Main", which in the LoadLibraryExW case is the time that GetProcAddress(hpython3, "Py_Main") is called. 

It turns out, when I tested this in 2017, that the loader in Windows 7 doesn't remember the activation context from loading "python3.dll" and thus will fail to find "python38.dll", which in turn makes the GetProcAddress() call fail. In contrast, the loader in Windows 10 knows to search for "python38.dll" in the directory of "python3.dll".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29399>
_______________________________________


More information about the Python-bugs-list mailing list