-
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
fix: Different MSVC versions may be ABI incompatible, guard with _MSC_VER (fix #2898) #4779
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for writing the great PR description!
@wjakob I think the same fix needs to be applied here: https://github.com/wjakob/nanobind/blob/1f65061db485dd8428a62842eb1dd0201db2dbd9/src/nb_internals.cpp#L58-L63 |
@rwgk Won't this break ABI between already compiled extensions and new extensions compiled under this change? |
Yes, but I believe it's the lesser of two evils. Based on @pwuertz's input I got to believe the current situation is very bad. Peter listed 8 bugs. I assume those are only a tiny fraction of cases where the ABI incompatibility caused crashes or confusion. The sooner we fix it the better. I think it's unavoidable that initially the next release might break some workflows, but once it's baked in everybody will be better off. |
Oh! We probably should up the internals version for Windows at the same time. |
No, this PR doesn't change the ABI of pybind11 modules at all. It just changes the namespace in which modules are communicating in. Or is your concern that any two independently compiled modules are now ending up in different namespaces and thus unexpectedly won't be sharing Pybind11 currently doesn't provide a way of declaring and asserting that for example a
If I understood its intent correctly, the |
To answer the simple question first:
That's correct, but it's kind-of the other way around:
More later. |
Yes. — That's what I had in mind with "lesser of two evils." — Currently we have a many-to-many mapping (MSVC version X to Y). A subset of those are "good", the rest is "bad". I don't think we have a reasonable way to tell those apart. The only choice we have is how quickly we transition from many-to-many to one-to-one. Everything below is beyond the scope of this PR for sure.
Hm ... it doesn't tell you what you need, only that you need something. In the case of stl.h conversions it tries to be more helpful:
We could probably go a long way by pointing to a new doc section in that message, explaining the common situations. That would have no compile-time or runtime overhead. Another approach might be to keep track of what types have registered conversions anywhere in the process, e.g. based on a simple python Since we're hitting on |
See pybind11 issue pybind/pybind11#4779
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunate (and would love it if we could come up with something looser), but it's what we already do, and ppl can override if they know what they are doing.
See pybind11 issue pybind/pybind11#4779
Thanks @henryiii and @wjakob for supporting/adopting this change. |
…#4779. See comments there.
This is wrong. I looked at most of the issues mentioned and it is about mixing MSVC modules built with |
Well, sorry. What we need is constructive feedback, concretely a PR with how to do it right. pybind11 is a community project. Also, maybe you meant: this isn't complete enough yet? |
Oh you did: #4953 Looking. |
…ith _MSC_VER (pybind#2898) (pybind#4779)" This reverts commit 76b8858.
Description
Pybind11, currently by default, shares C++ data structures across DLLs built with different MSVC versions, for which there is no documented guarantee for ABI compatibility. This has caused difficult-to-track crashes on several occasions for quite some time now (#1562, #1618, #2898, onnx/onnx#3493, pytorch/pytorch#62090, pytorch/pytorch#84457, NVIDIA/TensorRT#2853, IntelRealSense/librealsense#8570).
This PR aims to mitigate the risk of an ABI mismatch in pybind11-module interaction by guarding against different MSVC compiler/lib/toolchain versions, without causing significant changes for pybind11 (see also discussion in #2898).
Suggested changelog entry: