pybind / pybind/pybind11

[BUG] - crash on c++ exception when importing 2 pybind submodules built from different MSVC versions

Open
#2,898 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Issue description

Update: After diving deep in the pybind11 comments inside the code (Thanks God for it!) I am rephrasing the issue.

It looks like different MSVC versions that build modules with pybind11 interfere with each other (due to use of common resources between python modules).
The PYBIND11_INTERNALS_ID string is not constructed from a _MSC_VER and when I miss match modules build with MSVC 14.0
and MSVC >= 14.2 the ID is the same and I get a crash

Here is the crash stack

image

image

The "registered_exception_translators" list is not empty, but once you try to access the translator you get access violation.

I saw the "PYBIND11_COMPILER_TYPE" definition can be override,
I guess what I see here is that mismatch between MSVC versions also cause problems and perhaps should be considered as a different ABI.

Question:
What are the benefits of using the same "Internals" between modules? is it memory consumption?
It seems like if I force override the ABI version it works (add_definitions(-DPYBIND11_COMPILER_TYPE="_testing")

This is my workaround for now, I can suggest a PR that integrate MSC version as part of the ABI_ID..

Thanks

Thanks
Nir

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing PYBIND11_INTERNALS_ID, PYBIND11_COMPILER_TYPE, and the registered_exception_translators list in the pybind11 implementation; no file or test is named in the issue. Reproduce imports of submodules built with MSVC 14.0 and MSVC >= 14.2, then establish whether the ABI identity must distinguish these compiler versions and verify that exception translation no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.