You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I've split the feature flags at need more than once. This seems reasonable. Something like "avoid long borrowed refs" or "avoid unique borrowed refs" might catch the idea of not keeping borrowed refs around for too long, and of not even keeping borrowed refs of things that we control.
It's worth trying out to see if this has a practical advantage, though. The two PyPy specific feature flags ended up going hand in hand almost all of the time, so there wasn't really a good reason to keep them after I had introduced them everywhere. They're still there.
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.The text was updated successfully, but these errors were encountered: