-
Notifications
You must be signed in to change notification settings - Fork 193
fix: Fix segfault during shutdown when using Triton metrics in Python backend #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b24c8a7
1547ae8
3bb3db7
59cbe6d
a7d9cb8
cda7ced
e967f7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1059,13 +1059,7 @@ Stub::~Stub() | |||||||||
| } | ||||||||||
| #endif | ||||||||||
|
|
||||||||||
| // Ensure the interpreter is active before trying to clean up. | ||||||||||
| if (Py_IsInitialized()) { | ||||||||||
| py::gil_scoped_acquire acquire; | ||||||||||
| py::object async_event_loop_local(std::move(async_event_loop_)); | ||||||||||
| py::object background_futures_local(std::move(background_futures_)); | ||||||||||
| py::object model_instance_local(std::move(model_instance_)); | ||||||||||
| } | ||||||||||
| DestroyPythonObjects(); | ||||||||||
|
|
||||||||||
| stub_message_queue_.reset(); | ||||||||||
| parent_message_queue_.reset(); | ||||||||||
|
|
@@ -1088,6 +1082,11 @@ Stub::GetOrCreateInstance() | |||||||||
| void | ||||||||||
| Stub::DestroyInstance() | ||||||||||
| { | ||||||||||
| if (!stub_instance) { | ||||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| stub_instance->DestroyPythonObjects(); | ||||||||||
| stub_instance.reset(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -1503,6 +1502,20 @@ Stub::GetCUDAMemoryPoolAddress(std::unique_ptr<IPCMessage>& ipc_message) | |||||||||
| #endif | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void | ||||||||||
| Stub::DestroyPythonObjects() | ||||||||||
|
whoisj marked this conversation as resolved.
|
||||||||||
| { | ||||||||||
| // Ensure the interpreter is active before trying to clean up. | ||||||||||
| if (Py_IsInitialized()) { | ||||||||||
| py::gil_scoped_acquire acquire; | ||||||||||
| py::object async_event_loop_local(std::move(async_event_loop_)); | ||||||||||
| py::object background_futures_local(std::move(background_futures_)); | ||||||||||
| py::object model_instance_local(std::move(model_instance_)); | ||||||||||
|
||||||||||
| py::object model_instance_local(std::move(model_instance_)); | |
| py::object model_instance_local(std::move(model_instance_)); | |
| py::object deserialize_bytes_local(std::move(deserialize_bytes_)); | |
| py::object serialize_bytes_local(std::move(serialize_bytes_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whoisj What do you think about this? Should we listen copilot here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the other fields are not a problem, then it doesn't matter, honestly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stub::DestroyInstance()unconditionally dereferencesstub_instance. IfDestroyInstance()is called beforeGetOrCreateInstance()(or called twice), this will crash. Add a null check (e.g., early-return if!stub_instance) before callingDestroyPythonObjects()/reset().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅