GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — gh-140798: Fix memory leak with `threading.local` when finalizer resurrects `threading_local_key` by efimov-mikhail · Pull Request #140836 · python/cpython Conversation
|
|
Thanks for the review, Sergey! But I have to say that I've discovered one even more difficult case without tracing at all: import _thread import threading local = _thread._local() class ClassWithDel: def __del__(self): getattr(local, 'c', None) def thread_func(): local.c = ClassWithDel() t = threading.Thread(target=thread_func) t.start() t.join() There's a leak with ASAN since finalizer of CC @mpage @colesbury @ambv as author and reviewers of #121655. Btw, we can merge this as is and create another issue for this case if this will be clearer. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This does not look like the right approach to me. I think you will end up playing whac-a-mole where each time you "fix" one leak you will introduce other bugs. You need a robust approach to dealing with finalizers like the GC has. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for the comment, @colesbury . And I'll be grateful for some piece of advice, if possible. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think you just haven't yet found the new bugs that this PR introduces. The original bug report was only found via fuzzing. I suspect that if you keep fuzzing you will find different ones with this PR. The problems is that we have code in the form: The underlying problem is that when you clear For example, if you move |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
In general, I agree with you, swapping clear function calls isn't good way of fixing anything. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It seems that we should find new solution.
threading.local when tracing is activethreading.local when finalizer resurrects thread_local_key
threading.local when finalizer resurrects thread_local_keythreading.local when finalizer resurrects threading_local_key
|
Friendly ping, @colesbury @vstinner @mpage |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.