Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue28653

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:refleak in C functools.lru_cache
Type:resource usageStage:resolved
Components:Library (Lib)Versions:Python 3.7, Python 3.6, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: yselivanovNosy List: gvanrossum, larry, levkivskyi, ned.deily, python-dev, serhiy.storchaka, yselivanov
Priority:release blockerKeywords:patch

Created on2016-11-09 23:47 byyselivanov, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
refleak.patchyselivanov,2016-11-09 23:47review
Messages (12)
msg280468 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2016-11-09 23:47
The attached patch fixes a refleak in functools.lru_cache.
msg280470 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-11-09 23:49
LGTM.
msg280471 -(view)Author: Ivan Levkivskyi (levkivskyi)*(Python committer)Date: 2016-11-09 23:51
FWIW, if I comment out this codetry:    from _functools import _lru_cache_wrapperexcept ImportError:    passin functools.py to use the pure Python version, then I get much larger numbers:$ ./python -m test -R : test_typingRun tests sequentially0:00:00 [1/1] test_typingbeginning 9 repetitions123456789.........test_typing leaked [25003, 25003, 25003, 25003] references, sum=100012test_typing leaked [9350, 9352, 9352, 9352] memory blocks, sum=37406test_typing failed
msg280472 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-11-09 23:57
New changesetba59f3328032 by Yury Selivanov in branch '3.5':Issue#28653: Fix a refleak in functools.lru_cache.https://hg.python.org/cpython/rev/ba59f3328032New changeset5b253d641826 by Yury Selivanov in branch '3.6':Merge 3.6 (issue#28653)https://hg.python.org/cpython/rev/5b253d641826New changeset784fea019cab by Yury Selivanov in branch 'default':Merge 3.6 (issue#28653)https://hg.python.org/cpython/rev/784fea019cab
msg280473 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2016-11-10 00:03
> FWIW, if I comment out this codeOh boy... This is something else. Please re-open#28649 explaining that it now leaks with pure-Python lru_cache.  Could you please take a look at it?
msg280474 -(view)Author: Ivan Levkivskyi (levkivskyi)*(Python committer)Date: 2016-11-10 00:10
It seems to be unrelated to typing.pyWith your test from test_functools:    def test_lru_type_error(self):        @functools.lru_cache(maxsize=None)        def infinite_cache(o):            pass        with self.assertRaises(TypeError):            infinite_cache([])I get [2, 2, 2, 2] for unpatched C version (this is now fixed)and [24764, 24764, 24764, 24764] for Python version.Should I maybe open a separate issue for this?
msg280475 -(view)Author: Ivan Levkivskyi (levkivskyi)*(Python committer)Date: 2016-11-10 00:13
Anyway, this is not urgent, typing.py uses the default version, which is the C version.
msg280476 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2016-11-10 00:13
> It seems to be unrelated to typing.pyWow. I can reproduce refleaks in test_typing, but not in test_functools. This is weird.
msg280477 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2016-11-10 00:17
> Anyway, this is not urgentNot so sure, a refleak in pure-python version kind of scares me.  It can be a bug in the core.
msg280478 -(view)Author: Ivan Levkivskyi (levkivskyi)*(Python committer)Date: 2016-11-10 00:26
> Wow. I can reproduce refleaks in test_typing, but not in test_functools. This is weird.Indeed, I copied the new test from test_functools to test_typing, but now I see that pure Python version of lru_cache fails even if I remove this test and test that was previously failing with C version (test_extended_generic_rules_eq).> Not so sure, a refleak in pure-python version kind of scares me.  It can be a bug in the core.Indeed. Now we need to figure out what it so special about typing that triggers the leak.
msg280479 -(view)Author: Ivan Levkivskyi (levkivskyi)*(Python committer)Date: 2016-11-10 00:43
I am not sure what does this mean, but when I remove __slots__ = () from some classes, numbers of leaked references change.
msg280480 -(view)Author: Yury Selivanov (yselivanov)*(Python committer)Date: 2016-11-10 01:11
Ivan, I think I figured it out, I'll close this one and reopen the typing one.
History
DateUserActionArgs
2022-04-11 14:58:39adminsetgithub: 72839
2016-11-10 01:11:57yselivanovsetstatus: open -> closed
title: refleak in functools.lru_cache -> refleak in C functools.lru_cache
messages: +msg280480

resolution: fixed
stage: needs patch -> resolved
2016-11-10 00:43:18levkivskyisetmessages: +msg280479
2016-11-10 00:26:52levkivskyisetmessages: +msg280478
2016-11-10 00:17:26yselivanovsetmessages: +msg280477
2016-11-10 00:14:26yselivanovsetstage: commit review -> needs patch
2016-11-10 00:13:35yselivanovsetmessages: +msg280476
2016-11-10 00:13:16levkivskyisetmessages: +msg280475
2016-11-10 00:10:29levkivskyisetmessages: +msg280474
2016-11-10 00:03:00yselivanovsetmessages: +msg280473
2016-11-09 23:57:17python-devsetnosy: +python-dev
messages: +msg280472
2016-11-09 23:51:37levkivskyisetnosy: +levkivskyi
messages: +msg280471
2016-11-09 23:49:34serhiy.storchakasetassignee:yselivanov
messages: +msg280470
stage: patch review -> commit review
2016-11-09 23:47:28yselivanovcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp