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.
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.