-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[TMA] Increment refcount for Py_None in TMA descriptor runtime helpers #4679
Conversation
Summary: Increment refcount for Py_None in TMA descriptor runtime helpers to avoid deallocating the None object. This fixes a runtime failure like Fatal Python error: none_dealloc: deallocating None
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.
Looks fine to me although I'm not an expert in python runtime/ref counting. If someone else can confirm it is the right thing to do that would be great
If we return a |
BTW, @htyu I just discussed with Thomas, there seem to be other places we didn't increment |
Sure, let me do that. |
Landing it now as the mi300 test failure seem an infra issue. |
@@ -274,6 +274,7 @@ static PyObject *setPrintfFifoSize(PyObject *self, PyObject *args) { | |||
} | |||
|
|||
Py_END_ALLOW_THREADS; | |||
Py_INCREF(Py_None); | |||
return Py_None; |
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.
For future reference there is a Py_RETURN_NONE
macro which does this in one line. And yes we should always increment the refcount even for constants like Py_None
or Py_False
.
Incrementing refcount for Py_None in TMA descriptor runtime helpers to avoid deallocating the None object. This fixes a runtime failure like
Fatal Python error: none_dealloc: deallocating None