Replies: 4 comments 15 replies
-
I'm confused TBH. Trying to get a handle on it:
--- a/include/pybind11/detail/internals.h
+++ b/include/pybind11/detail/internals.h
@@ -39,7 +39,11 @@
# if PY_VERSION_HEX >= 0x030C0000 || defined(_MSC_VER)
// Version bump for Python 3.12+, before first 3.12 beta release.
// Version bump for MSVC piggy-backed on PR #4779. See comments there.
-# define PYBIND11_INTERNALS_VERSION 5
+# ifdef Py_GIL_DISABLED
+# define PYBIND11_INTERNALS_VERSION 6
+# else
+# define PYBIND11_INTERNALS_VERSION 5
+# endif
# else
# define PYBIND11_INTERNALS_VERSION 4
# endif That introduced a
However:
The only problematic situation I'd expect: If you have a base class in one extension module using internals version A, and a derived class in another extension module using internals version B. (Both extensions would have to either use master or smart_holder, you couldn't use a mix.) All other cross-extension functionality should work based on the conduit feature. The only requirement is that the |
Beta Was this translation helpful? Give feedback.
-
I looked back on the smart_holder branch to remind myself, keeping track of it here for easy future reference:
The only way to avoid this weird complexity is to merge smart_holder into master. But at least, since #5296 it doesn't matter much anymore if the smart_holder internals version is different. We need to be careful though to correctly reflect internals changes on master and internals changes on the smart_holder branch in the internals version numbers. |
Beta Was this translation helpful? Give feedback.
-
To close the loop here:
(These are steps towards merging smart_holder into master.) |
Beta Was this translation helpful? Give feedback.
-
I only found time today to re-evaluate different combinations of the
It turns out that they are only compatible if the
|
Beta Was this translation helpful? Give feedback.
-
Hi @rwgk,
first of all: thanks for your continued efforts to merge
smart_holder
andmaster
branches.I have been using both branches in parallel for quite a while, having some modules built with official releases (
master
) and some building directly fromsmart_holder
branch. This worked quite well so far, usingPYBIND11_INTERNALS_VERSION=4
for both branches.Recently, I discovered a segfault in this 9-month-old configuration, which turned out to be an ABI incompatibility. Fortunately, due to your efforts, the issue was already fixed in #5257. However, forwarding to this commit broke compatibility between
master
andsmart_holder
as the latter was fixed toPYBIND11_INTERNALS_VERSION=6
by default:pybind11/include/pybind11/detail/internals.h
Lines 39 to 40 in 48f2527
Only recently, the
master
branch was upgraded toPYBIND11_INTERNALS_VERSION=6
as well (#5512).However, 3 days ago, you increased
PYBIND11_VERSION_MAJOR -> 3
andPYBIND11_INTERNALS_VERSION -> 106
, again breaking ABI compatibility:pybind11/include/pybind11/detail/internals.h
Lines 40 to 41 in 7d37eb9
Thus, currently we have only a single combination of
master
(#5512) andsmart_holder
(664876e) branches being compatible.EDIT: One can explicitly enforce
PYBIND11_INTERNALS_VERSION=6
on release versions >= 2.13.1.The
smart_holder
branch, on the other hand, does not work withPYBIND11_INTERNALS_VERSION<6
. This should be asserted:What is really annoying about the current situation, is that we cannot detect ABI incompatibility anymore: Previously, I used the number of
__builtins__
keys starting with__pybind11_internals_v
as an indicator for the number of different ABI versions loaded:However, this doesn't work anymore since #5257 doesn't expose this key anymore. Now, I need to correctly interpret
TypeError
exceptions like these:However, these also popup if the types are not exposed at all (instead of being hidden in some incompatible module).
Hence, my suggestion: Perform a sanity check when loading an extension module and throw a warning when multiple different ABI versions are mixed. Consider all
PYBIND11_INTERNALS_VERSION
>= 4. I hope, there is an easy way to do so.Beta Was this translation helpful? Give feedback.
All reactions