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

Split CYTHON_AVOID_BORROWED_REFS into two levels? #6164

Open
da-woods opened this issue Apr 25, 2024 · 1 comment
Open

Split CYTHON_AVOID_BORROWED_REFS into two levels? #6164

da-woods opened this issue Apr 25, 2024 · 1 comment

Comments

@da-woods
Copy link
Contributor

Describe your issue

My proposal is that we should probably be using CYTHON_AVOID_BORROWED_REFS for the nogil build, because borrowed references are an opportunity for nasty reference-counting races.

However, there are also places where it's unnecessary - for example in Cython utility code where we're dealing an element of a tuple that we've just created and has not yet been exposed to any other threads.

My proposal is that we add two levels of CYTHON_AVOID_BORROWED_REFS:

  • CYTHON_AVOID_BORROWED_REFS == 1 is what we currently do. It's largely targeted at implementations like PyPy where borrowed references confuse their C API implementation, and it tries to be fairly thorough.
  • CYTHON_AVOID_BORROWED_REFS == 2 is targeted at the nogil build and only avoids borrowed references where there's a danger than objects might be on multiple threads.
@scoder
Copy link
Contributor

scoder commented Apr 25, 2024 via email

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

No branches or pull requests

2 participants