-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
triageNew bug, unverifiedNew bug, unverified
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
3.0.0
Problem description
The following code about virtual inheritance relationship , i use smart_holder
instead of std::shared_ptr
.
class Animal {
public:
virtual std::shared_ptr<Animal> clone() const = 0;
virtual ~Animal() = default;
};
class Cat : virtual public Animal {
public:
virtual ~Cat() override = default;
};
class Tiger : virtual public Cat {
public:
Tiger() = default;
Tiger(const Tiger &) = default;
~Tiger() override = default;
std::shared_ptr<Animal> clone() const override {
return std::make_shared<Tiger>(*this);
}
};
void bind_animals(pybind11::module_ &module) {
pybind11::class_<Animal, pybind11::smart_holder>(module, "Animal");
pybind11::class_<Cat, Animal, pybind11::smart_holder>(module, "Cat");
pybind11::class_<Tiger, Cat, pybind11::smart_holder>(
module, "Tiger", pybind11::multiple_inheritance())
.def(pybind11::init<>())
.def("clone", &Tiger::clone);
}
In python code:
tiger = Tiger()
tiger.clone()
An error occurred:
due to a fatal error condition:
SIGSEGV - Segmentation violation signal
But it is ok to use std::shared_ptr
as py::class_
holder. Are there problems with my usage of the smart_holder
.
Can anyone help me with this? It's urgent. Thank you very much!
Is this a regression? Put the last known working version here if it is.
Not a regression
Metadata
Metadata
Assignees
Labels
triageNew bug, unverifiedNew bug, unverified