-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
test_tools are leaked #107458
Comments
Bisected to #107287 |
I think problem is here: cpython/Lib/test/support/import_helper.py Lines 253 to 268 in a24e25d
|
I cannot reproduce it on Ubuntu 22.04. HEAD->6e850c30bb70 |
root@codespaces-62bef3 /w/cpython (main)# ./python -m test -R 3:3 test_decimal
0:00:00 load avg: 1.52 Run tests sequentially
0:00:00 load avg: 1.52 [1/1] test_decimal
./Modules/_decimal/libmpdec/context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time
beginning 6 repetitions
123456
......
== Tests result: SUCCESS ==
1 test OK.
Total duration: 29.3 sec
Tests result: SUCCESS This suggests the problem lies within this test. |
Minimal bug reproducer: import sys
import unittest
import importlib
from test.support import import_helper
class TestDecimalRefleak(unittest.TestCase):
def test_refleak(self):
old_modules = import_helper.modules_setup()
decimal = importlib.import_module("decimal")
import_helper.modules_cleanup(*old_modules) |
If we add this line |
As far as I understand, |
As you said. If you add this statement, |
Oh, I suddenly discovered another issue with import sys
import unittest
import importlib
from test.support import import_helper
class TestDecimalRefleak(unittest.TestCase):
def test_refleak(self):
old_modules = import_helper.modules_setup()
socket = importlib.import_module("_socket")
import_helper.modules_cleanup(*old_modules)
Traceback:
./python.exe -m test -R 3:3 test_refleak
0:00:00 load avg: 2.22 Run tests sequentially
0:00:00 load avg: 2.22 [1/1] test_refleak
beginning 6 repetitions
123456
......
test_refleak leaked [219, 219, 219] references, sum=657
test_refleak leaked [144, 144, 144] memory blocks, sum=432
test_refleak failed (reference leak)
== Tests result: FAILURE ==
1 test failed:
test_refleak
Total duration: 150 ms
Tests result: FAILURE |
Above the same problem, socket_exec called multiple times. |
More simple reproducer: import sys
import unittest
import importlib
class TestDecimalRefleak(unittest.TestCase):
def test_refleak(self):
importlib.import_module("_decimal")
sys.modules.pop("_decimal") |
Tried on current main
Linked PRs
The text was updated successfully, but these errors were encountered: