Skip to content

Avoid double free the global onnxloader when system exit#314

Open
liuwei-git wants to merge 1 commit intotriton-inference-server:mainfrom
liuwei-git:wei/avoid_loader_double_free
Open

Avoid double free the global onnxloader when system exit#314
liuwei-git wants to merge 1 commit intotriton-inference-server:mainfrom
liuwei-git:wei/avoid_loader_double_free

Conversation

@liuwei-git
Copy link

@liuwei-git liuwei-git commented Aug 8, 2025

Issue to fix:

The static OnnxLoader::loader object may be destroyed by the system before the customer's cleanup code (e.g., TRITONSERVER_ServerDelete) runs.
This premature destruction causes an assertion failure inside ONNX Runtime initially. Even if the assertion is suppressed, it leads to double-free errors detected by the system during shutdown.

Proposed solution:

Modify the OnnxLoader destructor to explicitly set the internal pointer to nullptr.
This ensures that subsequent null checks on loader in UnloadSession and Stop methods function correctly, preventing use-after-free or double-free issues.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant