There is no need to inherit from std::enable_shared_from_this; and this was causing problems as HybridObject may not always be contained in a shared_ptr (case where creation is triggered by C code). Instead, since the refcounting is done by the HybridObject, it is easy to instanciate shared_ptr<> automatically calling unref(), at any time, when needed.