Repository navigation
Refleak in test_importlib on aarch64 RHEL8 #101766
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Feb 9, 2023 First failing build that I was able to find: https://buildbot.python.org/all/#/builders/802/builds/582
See #101394
Linux 65cf87cd990d 6.1.9-200.fc37.aarch64 #1 SMP PREEMPT_DYNAMIC Thu Feb 2 00:41:31 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
beginning 6 repetitions 123456 ...... test_importlib leaked [134, 134, 134] references, sum=402 test_importlib leaked [56, 56, 56] memory blocks, sum=168 test_importlib failed (reference leak) == Tests result: FAILURE == 1 test failed: test_importlib Total duration: 598 ms Tests result: FAILURE ran 1 tests/2 exit 2 Tests failed: continuing with this subtest Tests (1): * test.test_importlib.test_metadata_api.APITests.test_version_egg_info_file Bisection completed in 16 iterations and 0:00:21 [root@65cf87cd990d cpython]#@corona10 If you found a suspect can you link it here?
@corona10 If you found a suspect can you link it here?
Sure
@gvanrossum @sobolevn @mdickinson @brettcannon @exarkun
I finally found the suspect:
commit: 3325f05
PR: #94504I run
./python -m test test_importlibrepeatedly 10 times onaarch64 RHEL8(rockylinux:8.7)with every single bisect commit :(
When I revert the 3325f05, no more leak is detected.The root cause has yet to be discovered.
Reacted by sobolevnReacted by sobolevnIs the SEND fix it?
@corona10 great work, thank you!
Is the SEND fix it?
Do you mean c776624? No, it doesn't solve the issue.
Usually leaks are C code. There is no C code in the importlib PR. Maybe the blocking_on dict needs to be cleared?
Usually leaks are C code.
I think sameway.
Maybe the blocking_on dict needs to be cleared?
I will try it.
Maybe the blocking_on dict needs to be cleared?
Yeah, this was the root cause. Amazing intuition!!
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index bebe7e15cb..e42e7bc653 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -85,6 +85,7 @@ def __enter__(self): def __exit__(self, *args, **kwargs): """Remove self.lock from this thread's _blocking_on list.""" self.blocked_on.remove(self.lock) + del _blocking_on[self.thread_id]
I am checking the proper solution.
Whenever there's a global cache you get things like this, I've debugged these since 2000. :-)
Good work finding the missing
del! And thanks for the hard work doing bisection.Also @sobolevn thanks for flagging this -- I had seen this occasionally but always just ignored it as being a flake. It was so much more than that!
All in all great teamwork.
Reacted by Donghee Na and sobolevnClose this issue
And thank you for reporting this issue @sobolevn!!!Re-open the issue due to #101942 (comment)
- added a commit that references this issue
on Feb 17, 2023
I am not sure what is going on with this test run:
See https://buildbot.python.org/all/#builders/802/builds/623
Linked PRs