-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-101766: Fix refleak for _BlockingOnManager resources #101942
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,11 @@ def __enter__(self): | |
def __exit__(self, *args, **kwargs): | ||
"""Remove self.lock from this thread's _blocking_on list.""" | ||
self.blocked_on.remove(self.lock) | ||
if len(self.blocked_on) == 0: | ||
# gh-101766: glboal cache should be cleaned-up | ||
# if there is no more _blocking_on for this thread. | ||
del _blocking_on[self.thread_id] | ||
del self.blocked_on | ||
Comment on lines
+88
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @corona10 @gvanrossum @sobolevn This change re-introduces the re-entrancy bug that Consider: A thread has executed I recommend reverting this change until a re-entrant safe version of the fix can be determined. The resource leak is not great but if I understand correctly, it is also more or less academic right now (it causes a very small amount of memory to be wasted while the test suite is running). The re-entrancy bug is real and breaks many real applications in extremely confusing ways (consider that the original bug reports were open for years before anyone tracked down the problem, at great expense, and it took more than half a year to get the fix reviewed and merged). Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @exarkun cc @gvanrossum @sobolevn And also would you like to submit the test code to prevent regression? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks you very much.
That would be ideal, certainly. There is a reproducer on #94504 but it is CPU intensive and non-deterministic without additional instrumentation inside |
||
|
||
|
||
class _DeadlockError(RuntimeError): | ||
|
Uh oh!
There was an error while loading. Please reload this page.