Repository navigation
Replies: 4 comments 16 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
# endifThat 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 |
|
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. |
|
To close the loop here:
(These are steps towards merging smart_holder into master.) |
|
I only found time today to re-evaluate different combinations of the
It turns out that they are only compatible if the
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @rwgk,
first of all: thanks for your continued efforts to merge
smart_holderandmasterbranches.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_holderbranch. This worked quite well so far, usingPYBIND11_INTERNALS_VERSION=4for 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
masterandsmart_holderas the latter was fixed toPYBIND11_INTERNALS_VERSION=6by default:pybind11/include/pybind11/detail/internals.h
Lines 39 to 40 in 48f2527
Only recently, the
masterbranch was upgraded toPYBIND11_INTERNALS_VERSION=6as well (#5512).However, 3 days ago, you increased
PYBIND11_VERSION_MAJOR -> 3andPYBIND11_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=6on release versions >= 2.13.1.The
smart_holderbranch, 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_vas 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
TypeErrorexceptions 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.All reactions