Skip to content

test_doctest are leaked #106843

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

Closed
Eclips4 opened this issue Jul 17, 2023 · 3 comments
Closed

test_doctest are leaked #106843

Eclips4 opened this issue Jul 17, 2023 · 3 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Jul 17, 2023

Tried on current main.

 ./python -m test -R 3:3 test_doctest
Running Debug|x64 interpreter...
0:00:00 Run tests sequentially
0:00:00 [1/1] test_doctest
beginning 6 repetitions
123456
<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.<frozen importlib._bootstrap>:824: ImportWarning: TestImporter.exec_module() not found; falling back to load_module()
.
test_doctest leaked [34, 34, 34] memory blocks, sum=102
test_doctest failed (reference leak) in 34.8 sec

== Tests result: FAILURE ==

1 test failed:
    test_doctest

Total duration: 34.9 sec
Tests result: FAILURE

Linked PRs

@Eclips4 Eclips4 added the type-bug An unexpected behavior, bug, or error label Jul 17, 2023
@Eclips4
Copy link
Member Author

Eclips4 commented Jul 17, 2023

Bisected to #106411
cc @methane

@AlexWaygood AlexWaygood added the tests Tests in the Lib/test dir label Jul 17, 2023
@sunmy2019
Copy link
Member

sunmy2019 commented Jul 18, 2023

This fixes the problem.

diff --git a/Python/compile.c b/Python/compile.c
index b80f7c01bcd..6a144f30164 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -8060,7 +8060,9 @@ _PyCompile_CleanDoc(PyObject *doc)
     }
 
     Py_DECREF(doc);
-    return PyUnicode_FromStringAndSize(buff, w - buff);
+    PyObject* res = PyUnicode_FromStringAndSize(buff, w - buff);
+    PyMem_Free(buff);
+    return res;
 }
 

@methane
Copy link
Member

methane commented Jul 18, 2023

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants