microsoft / microsoft/onnxruntime-genai
Application crashes on exit with v0.5.0
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 354
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 85
Description
The latest release (v0.5.0) introduces additional checks designed to prevent resource leaks that will cause an application to crash unless some explicit changes are made. This can be easily reproduced with the sample code included in the README file of the [Microsoft.ML.OnnxRuntimeGenAI](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntimeGenAI/0.5.0) package.
Executing this code as is will result in a crash when the application exits after displaying the following message:
```
Error: Shutdown must be called before process exit, please check the documentation for the proper API to call to ensure clean shutdown.
```
Proper disposal of the OgaHandle instance fixes the issue
Replace
```C#
OgaHandle ogaHandle = new OgaHandle();
```
With this
```C#
using OgaHandle ogaHandle = new OgaHandle();
```
I couldn't find documentation regarding the `OgaHandle`, nor many examples that use it, considering how essential it seems to be. This impacts applications using the ONNX Connector in Semantic Kernel, which currently is not aware of this new requirement (see https://github.com/microsoft/semantic-kernel/issues/9628).
While making it easier to diagnose resource leaks is always welcome, crashing the application seems a bit heavy handed. Maybe just keep the error messages but remove the forced shutdown?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the sample code in the Microsoft.ML.OnnxRuntimeGenAI README and the OgaHandle lifecycle described in the issue. Reproduce the v0.5.0 exit crash, then inspect the shutdown behavior and available documentation; done means the sample exits cleanly with the intended resource-leak diagnostics or clearly documents the required disposal API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100