Skip to content

Python constructors do not keep the referenced behaviour alive #293

Description

@trsxvz

bindings/python/src/BehaviourData.cxx:41; bindings/python/src/MaterialDataManager.cxx:77-79; bindings/python/src/MaterialStateManager.cxx:219-221.

Finding. These constructors take a const Behaviour& that the C++ object stores as a reference. None of them declares a keep-alive.

Effect. Constructing directly from a freshly loaded behaviour, without holding it in a variable, leaves the stored reference dangling. Every later call that reads the behaviour is then undefined behaviour. The tests avoid it by accident, because they keep the behaviour in a variable.

Fix. Add a keep-alive between the new object and its behaviour argument on each of these constructors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpython bindingsAnything related to the python-bindings

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions