Skip to content
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

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

htyu
Copy link
Collaborator

@htyu htyu commented Sep 9, 2024

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

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
Copy link
Collaborator

@ThomasRaoux ThomasRaoux left a 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

@Jokeren
Copy link
Contributor

Jokeren commented Sep 9, 2024

If we return a Py_None, I do think it's a good practice to increment its count.

@Jokeren
Copy link
Contributor

Jokeren commented Sep 9, 2024

BTW, @htyu I just discussed with Thomas, there seem to be other places we didn't increment Py_None. Do you mind fixing them as well?

@htyu
Copy link
Collaborator Author

htyu commented Sep 9, 2024

BTW, @htyu I just discussed with Thomas, there seem to be other places we didn't increment Py_None. Do you mind fixing them as well?

Sure, let me do that.

@htyu
Copy link
Collaborator Author

htyu commented Sep 9, 2024

Landing it now as the mi300 test failure seem an infra issue.

@htyu htyu merged commit 4b34a20 into triton-lang:main Sep 9, 2024
5 of 7 checks passed
@htyu htyu deleted the hoy/tma branch September 9, 2024 17:30
@@ -274,6 +274,7 @@ static PyObject *setPrintfFifoSize(PyObject *self, PyObject *args) {
}

Py_END_ALLOW_THREADS;
Py_INCREF(Py_None);
return Py_None;
Copy link
Contributor

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.

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.

4 participants