fix: intentionally leak onnxruntime objects to avoid crash

This should be reverted when it get fixed upstream
This commit is contained in:
dantmnf
2024-05-31 20:55:14 +08:00
parent d6572b2c7e
commit d2e5001e7e
2 changed files with 12 additions and 1 deletions

View File

@@ -98,3 +98,14 @@ bool asst::OnnxSessions::use_gpu(int device_id)
gpu_enabled = true;
return true;
}
asst::OnnxSessions::~OnnxSessions()
{
// FIXME: intentionally leak ort objects to avoid crash (double free?)
// https://github.com/microsoft/onnxruntime/issues/15174
auto leak_sessions = new decltype(m_sessions);
*leak_sessions = std::move(m_sessions);
auto leak_options = new Ort::SessionOptions(nullptr);
*leak_options = std::move(m_options);
}

View File

@@ -17,7 +17,7 @@ namespace asst
class OnnxSessions final : public SingletonHolder<OnnxSessions>, public AbstractResource
{
public:
virtual ~OnnxSessions() override = default;
virtual ~OnnxSessions();
virtual bool load(const std::filesystem::path& path) override;
Ort::Session& get(const std::string& name);