Skip to content

gh-135380: enhance critical section held assertions #135381

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jun 11, 2025

@kumaraditya303 kumaraditya303 requested a review from vstinner June 12, 2025 11:14
@vstinner
Copy link
Member

I kept it similar to mutex lock held function which uses Py_DEBUG not NDEBUG.

IMO it's worth it to replace #ifdef Py_DEBUG with #ifndef NDEBUG to support building Python with assertions in release mode: https://docs.python.org/dev/using/configure.html#cmdoption-with-assertions But I suggest doing that in a follow-up PR.

@@ -64,7 +64,7 @@ extern "C" {

# define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \
if (Py_REFCNT(op) != 1) { \
Copy link
Member

@vstinner vstinner Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense / would it be possible to move the REFCNT test inside _PyCriticalSection_AssertHeldObj() to make this macro a no-op when built in release mode without assertions?

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

Successfully merging this pull request may close these issues.

3 participants