-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Incompatible internals between versions #5420
Comments
Oops - I should have bumped the version number in the @vfdev-5 already bumped the version number in the pybind11/include/pybind11/detail/internals.h Lines 42 to 44 in f7e14e9
I'm not sure there's much to be done other than "don't use v2.13.1" with free-threaded builds. @rostan-t, are you aware of any free-threading compatible libraries that are pinned to v2.13.1? |
Scipy is FT compatible and pinning pybind11 as "pybind11>=2.13.1": |
ContourPy also pins |
ContourPy is fine. The latest release 1.3.0 (the only release that supports Python 3.13) was built using pybind11 2.13.5 on PyPI and 2.13.6 on conda-forge, confirmed using: python -c "import contourpy.util as u; print(u.build_config()['pybind11_version'])" I'll change the pin to |
SciPy also shouldn't be an issue; the 1.14.x branch doesn't support free-threading and has an upper bound of
PR has been merged in SciPy with the same change. |
Matplotlib 3.9.2 might be an issue. The cp313t PyPI wheels were built on the same day that pybind11 2.13.2 and 2.13.3 were released so they may have been built using pybind11 2.13.1, I don't know yet. |
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
v2.13.6
Problem description
Version 2.13.2 replaces
std::mutex
withPyMutex
instruct internals
(#5219) in free-threaded builds. This changes the size and alignment of fields ininternals
becausestd::mutex
occupies 40 bytes on x86-64 Linux whilePyMutex
only requires 1.This can lead to crashes if same program imports two libraries compiled resp. with pybind11 before and after 2.13.2. When the first library is imported, its first call to
detail::get_internals()
will find that the interpreter state dict doesn't yet contain an internal object, initialize one and store it (internals.h:541). When the next library is imported, it will load the object from the state dict and cast thevoid *
tointernals *
. At this point, no error occurs but the object is already corrupted. When the second library tries to use the cachedinternals
object, unexpected things such as segfaults will happen.A fix for this would be to put the mutex at the end of the structure.
Reproducible example code
Is this a regression? Put the last known working version here if it is.
v2.13.1
The text was updated successfully, but these errors were encountered: