[BUG]: Silent failure if python object is destroyed but shared_ptr to CPP object is held #4603
Open
3 tasks done
Labels
triage
New bug, unverified
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.10.4
Problem description
We have come across an issue concerning the combination of Python and CPP object lifetimes. If a Cpp class is exposed via pybind11 using a shared_ptr as a holder, it is possible to destroy the python object while retaining a shared_ptr to the Cpp object. However, the Cpp object behaviour reverts to the Cpp base class and all python behaviour is silently dropped.
Is the silent drop expected? We would either expect an exception when the object is used or to retain full functionality. We attached some simple example code below:
Reproducible example code
On the Cpp side:
On the Python side
And finally a CMakeLists.txt file to build
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered: