Skip to content

Fix: mass binding is defined to have multiple inheritance#325

Merged
damienmarchal merged 1 commit intosofa-framework:masterfrom
alxbilger:massmultipleinheritance
Dec 14, 2022
Merged

Fix: mass binding is defined to have multiple inheritance#325
damienmarchal merged 1 commit intosofa-framework:masterfrom
alxbilger:massmultipleinheritance

Conversation

@alxbilger
Copy link
Contributor

This is a fix for https://github.com/sofa-framework/BeamAdapter/discussions/86

The call of assembleKMatrix leads to a UB without the suggested change.

@damienmarchal
Copy link
Contributor

Here is what pybind docs says about that:

When only one base type is specified for a C++ type that actually has multiple bases, pybind11 will assume that it does not participate in multiple inheritance, which can lead to undefined behavior. In such cases, add the tag multiple_inheritance to the class constructor:

py::class_<MyType, BaseType2>(m, "MyType", py::multiple_inheritance());

The tag is redundant and does not need to be specified when multiple base types are listed.

So the PR is perfectly in the specified use case.

@damienmarchal damienmarchal merged commit 26b4611 into sofa-framework:master Dec 14, 2022
alxbilger added a commit to alxbilger/SofaPython3 that referenced this pull request Dec 14, 2022
The multiple inheritance property of Mass has been identified problematic in a previous pull request sofa-framework#325.

The test in this commit succeeds if Mass is defined with the label py::multiple_inheritance(). Otherwise it crashes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants