Open Eclips4 opened 1 year ago
seems to be introduced in #104798 cc @lysnikolaou
I think, this traceback more helpful:
Thanks, Lysandros is already working on this since yesterday. BTW, the failure is not Windows specific: https://buildbot.python.org/all/#/builders/320/builds/730/steps/5/logs/stdio
seems to be introduced in #104798
FTR, it is verified that #104798 introduced this.
Thanks, Lysandros is already working on this since yesterday. BTW, the failure is not Windows specific: https://buildbot.python.org/all/#/builders/320/builds/730/steps/5/logs/stdio
Indeed. I couldn't reproduce it on my WSL (Ubuntu 20.04), and thought that it's related to Windows system.
So, thanks for this point and removing os-windows label.
UPD: I was running test as ./python -m test -v test_peg_generator
on Linux, which doesn't cause test fail.
I'm somewhat unsure about changing the issue title. Seems there two issues: 1 - which described in this issue - test fail (Windows issue) 2 - refleak test fail, which reproducible on Linux (but on Windows we cannot get refleak test results, because of test failing) So, seems that there two problems, which probably will be solved by one PR
Enclosing my response in <details>
in order to not bring too much clutter and noise into this issue:
Thanks Erlend for your answer! I know about it all. After one situation with asyncio(eager-task merging) I've git clone and rebuilt interpreter every time when I find some fail. So, there's a some proof of my words:
@Eclips4, try with a UTF-8 setup.
@Eclips4, try with a UTF-8 setup.
Seems that with UTF-8 encoding test passes. But, cp1251 is a common encoding for Windows.
(Copied from #105087) Previously, test_peg_generator is skipped -- distutils has been removed in Python 3.12
Now it's added back in https://github.com/python/cpython/pull/104798 and is leaking references.
Recent builtbot results: https://buildbot.python.org/all/#/builders/259/builds/775
test_peg_generator leaked [68, 68, 68] references, sum=204
test_peg_generator leaked [52, 52, 52] memory blocks, sum=156
Seems all ref leaks come from Tools/peg_generator/pegen/build.py : compile_c_extension
But no matter how many times we call this function, the leaks are the same as if it was called once.
This behavior looks like a cache was created and forgotten.
FYI we still haven't been able to find a solution to this. We've bisected the problem down to a call to setuptools.Distribution
. I've opened an issue on this on pypa/setuptools#3938 to figure out what the correct course of action is.
Hi, I tracked down part of the ref leaks to this cache:
Setting
- cache_wrapper = cache_wrapper or functools.lru_cache()
+ cache_wrapper = cache_wrapper or functools.lru_cache(maxsize=0)
reduced the ref leaks.
Part of the reference seems (not sure) to come from
https://github.com/python/cpython/blob/3fe7d7c020a8b2d395a58bfafbe689ee36f7fe30/Modules/_ctypes/callproc.c#L1877-L1926
string LP_...
and string _type_
seem to be leaked.
The rest ref leaks all came from here
# cache for by mkpath() -- in addition to cheapening redundant calls,
# eliminates redundant "creating /foo/bar/baz" messages in dry-run mode
_path_created = {} # <-- not cleared
def mkpath(name, mode=0o777, verbose=1, dry_run=0): # noqa: C901
"""Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do nothing.
Raise DistutilsFileError if unable to create some directory along the way
(eg. some sub-path exists, but is a file rather than a directory).
If 'verbose' is true, print a one-line summary of each mkdir to stdout.
Return the list of directories actually created.
os.makedirs is not used because:
a) It's new to Python 1.5.2, and
b) it blows up if the directory already exists (in which case it should
silently succeed).
"""
That should be all for the ref leaks on Linux.
I will leave the fix to someone else. You can add me as the co-author of the fix if you wish to fix this.
@sunmy2019 Thanks a lot for spending time on this! I'll work on opening separate issues if needed and fixing those leaks, probably early next week.
@lysnikolaou, any updates on this? Perhaps we should skip rerunning these tests for now?
Unfortunately I didn't have the time to look into this further.
Perhaps we should skip rerunning these tests for now?
Yup, that's probably a good idea.
Keeping this open until a real fix is reintroduced.
Tried on curent main branch
Traceback
```python PS C:\Users\KIRILL-1\CLionProjects\cpython> ./python -m test -v test_peg_generator Running Debug|x64 interpreter... == CPython 3.13.0a0 (heads/main:1668b41dc4, May 29 2023, 18:02:21) [MSC v.1933 64 bit (AMD64)] == Windows-10-10.0.19043-SP0 little-endian == Python build: debug == cwd: C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ == CPU count: 16 == encodings: locale=cp1251, FS=utf-8 0:00:00 Run tests sequentially 0:00:00 [1/1] test_peg_generator Run: C:\Users\KIRILL-1\CLionProjects\cpython\PCbuild\amd64\python_d.exe -X dev -m venv venv Run: C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ\tempcwd\venv\Scripts\python_d.exe -X dev -m pip install C:\U sers\KIRILL-1\CLionProjects\cpython\Lib\test\setuptools-67.6.1-py3-none-any.whl C:\Users\KIRILL-1\CLionProjects\cpython\Lib\test\w heel-0.40.0-py3-none-any.whl Processing c:\users\kirill-1\clionprojects\cpython\lib\test\setuptools-67.6.1-py3-none-any.whl C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ\tempcwd\venv\Lib\site-packages\pip\_internal\metadata\importlib\_ dists.py:74: DeprecationWarning: Unimplemented abstract methods {'locate_file'} return cls(files, info_location) Processing c:\users\kirill-1\clionprojects\cpython\lib\test\wheel-0.40.0-py3-none-any.whl Installing collected packages: wheel, setuptools C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ\tempcwd\venv\Lib\site-packages\pip\_internal\metadata\importlib\_ dists.py:74: DeprecationWarning: Unimplemented abstract methods {'locate_file'} return cls(files, info_location) Successfully installed setuptools-67.6.1 wheel-0.40.0 C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ\tempcwd\venv\Lib\site-packages\pip\_internal\self_outdated_check. py:232: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware obje cts to represent datetimes in UTC: datetime.now(datetime.UTC). current_time=datetime.datetime.utcnow(), C:\Users\KIRILL-1\CLionProjects\cpython\build\test_python_11752æ\tempcwd\venv\Lib\site-packages\pip\_internal\utils\misc.py:130: D eprecationWarning: onerror argument is deprecated, use onexc instead shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler) Traceback (most recent call last): File "Linked PRs