[X] This is a pyzmq-specific bug, not an issue of zmq socket behavior. Don't worry if you're not sure! We'll figure it out together.
What pyzmq version?
26.1.0
What libzmq version?
not relevant
Python version (and how it was installed)
3.11.8 (but not really relevant)
OS
Win10
What happened?
pyzmq-installed msvcp140.dll is loaded once zmq is imported. This breaks any package linked against a newer MSVC C++ runtime.
Code to reproduce bug
First import zmq (which loads the included VC++ runtime DLL).
Next import any Python package that is linked against VC++ runtime 14.40.44810 or newer.
See how that Python package crashes, usually on the DLL initialiser machine, while it is trying to access a mutex.
Traceback, if applicable
No response
More info
Microsoft guarantee that their VC++ runtimes (the "MSVC Redist" packages) are backward compatible, but explicitly not forward compatible.
In 14.40.44810, released around May 2024, they have made a backward incompatible change (something to do with the initialisation of mutexes).
The effect of this is that anything that has been built against the current VC++ runtime will crash if at execution time it gets an older version of msvcp140. And if pyzmq is loaded first into the Python interpreter it will load its old copy of msvcp140, which causes later loaded module to use that copy (in stead of loading the correct copy from /Windows/system32/msvcp140.dll.
Microsoft used to suggest that everyone include VC++ redist in their installers, and while they don't do so any more I'm rather surprised that they don't warn against it. Because the problem not only happens with Python modules (as in this case) but also with any program that includes msvcp140 in a directory that gets prepended to %PATH%...
This is a pyzmq bug
What pyzmq version?
26.1.0
What libzmq version?
not relevant
Python version (and how it was installed)
3.11.8 (but not really relevant)
OS
Win10
What happened?
pyzmq-installed
msvcp140.dll
is loaded oncezmq
is imported. This breaks any package linked against a newer MSVC C++ runtime.Code to reproduce bug
Traceback, if applicable
No response
More info
Microsoft guarantee that their VC++ runtimes (the "MSVC Redist" packages) are backward compatible, but explicitly not forward compatible.
In 14.40.44810, released around May 2024, they have made a backward incompatible change (something to do with the initialisation of mutexes).
The effect of this is that anything that has been built against the current VC++ runtime will crash if at execution time it gets an older version of
msvcp140
. And if pyzmq is loaded first into the Python interpreter it will load its old copy of msvcp140, which causes later loaded module to use that copy (in stead of loading the correct copy from/Windows/system32/msvcp140.dll
.Microsoft used to suggest that everyone include VC++ redist in their installers, and while they don't do so any more I'm rather surprised that they don't warn against it. Because the problem not only happens with Python modules (as in this case) but also with any program that includes
msvcp140
in a directory that gets prepended to%PATH%
...