-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
gh-114203: skip locking if object is already locked by two-mutex critical section #141476
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
Conversation
|
The behavior looks correct to me. Would you please add a test for this behavior to |
I have added tests for reacquisition of both one and two mutex critical sections. |
|
LGTM: I think it deserves a NEWS entry I think we should backport to 3.14: it's low risk and avoids a class of bugs in third party extensions that will be annoying for everyone to deal with. @Yhg1s, what do you think? |
|
Yeah, I think it makes sense to backport. It doesn't really have downsides and as you say, avoids latent bugs in user code in some situations. I wish we could do more to flag those issues, but that's a task for better tooling (which we're also working on), not something we can improve on here. |
|
Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…x critical section (pythonGH-141476) (cherry picked from commit f26ed45) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
GH-141564 is a backport of this pull request to the 3.14 branch. |
This fixes the issue outlined in https://gist.github.com/kumaraditya303/05cd1c93577bd7f44f573dad61674842
If the object is currently locked by a two-mutex critical section then locking is skipped. Previously locking was skipped only in case where mutex was the first mutex of the two which is decided by memory address so was nondeterministic.