This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年04月09日 01:02 by Kevin Modzelewski, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| super_init_leaks.patch | serhiy.storchaka, 2016年04月12日 15:43 | review | ||
| super_init_leaks_2.patch | serhiy.storchaka, 2016年04月12日 18:47 | review | ||
| Messages (12) | |||
|---|---|---|---|
| msg263053 - (view) | Author: Kevin Modzelewski (Kevin Modzelewski) | Date: 2016年04月09日 01:02 | |
The super() __init__ function fills in the fields of a super object without checking if they were already set. If someone happens to call __init__ again, the previously-set references will end up getting forgotten and leak memory. For example: import sys print(sys.gettotalrefcount()) sp = super(int, 1) for i in range(100000): super.__init__(sp, float, 1.0) print(sys.gettotalrefcount()) |
|||
| msg263073 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年04月09日 07:05 | |
If super used __new__ instead of __init__, this issue probably wouldn't arise. I'm surprised that super is subclassable. |
|||
| msg263103 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2016年04月09日 16:28 | |
Any uses of super() beyond the documented idioms are uninteresting, except they should not be usable as crash or DoS vectors. |
|||
| msg263195 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2016年04月11日 18:01 | |
Based on Guido's feedback and the fact that this isn't documented usage of super() and hence no promises to not re-initialize, I'm closing as "not a bug". Sorry, Kevin. |
|||
| msg263196 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2016年04月11日 18:05 | |
Actually, the refcount bug is still a bug. |
|||
| msg263232 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年04月12日 06:31 | |
Possible solutions: 1. Correctly decref old values. 2. Raise an exception if super.__init__ is caled multiple times. 3. Remove super.__init__ and add super.__new__. What is more preferable? |
|||
| msg263249 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2016年04月12日 15:03 | |
Do #1. --Guido (mobile) On Apr 11, 2016 11:31 PM, "Serhiy Storchaka" <report@bugs.python.org> wrote: > > Serhiy Storchaka added the comment: > > Possible solutions: > > 1. Correctly decref old values. > 2. Raise an exception if super.__init__ is caled multiple times. > 3. Remove super.__init__ and add super.__new__. > > What is more preferable? > > ---------- > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue26718> > _______________________________________ > |
|||
| msg263253 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年04月12日 15:43 | |
Here is a patch. |
|||
| msg263254 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年04月12日 15:45 | |
super_init_leaks.patch LGTM, it fixes. I confirm that the patch fixes the refleak. I checked with: $ ./python -m test -R 3:3 test_super |
|||
| msg263270 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年04月12日 18:47 | |
Added more comments as suggested by Guido. |
|||
| msg263276 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年04月12日 20:42 | |
super_init_leaks_2.patch LGTM. |
|||
| msg263331 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年04月13日 12:30 | |
New changeset 450f36750cb9 by Serhiy Storchaka in branch '3.5': Issue #26718: super.__init__ no longer leaks memory if called multiple times. https://hg.python.org/cpython/rev/450f36750cb9 New changeset 4680438f486f by Serhiy Storchaka in branch '2.7': Issue #26718: super.__init__ no longer leaks memory if called multiple times. https://hg.python.org/cpython/rev/4680438f486f New changeset 55f4c1f8ca6a by Serhiy Storchaka in branch 'default': Issue #26718: super.__init__ no longer leaks memory if called multiple times. https://hg.python.org/cpython/rev/55f4c1f8ca6a |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:29 | admin | set | github: 70905 |
| 2016年04月13日 12:38:38 | serhiy.storchaka | set | status: open -> closed assignee: serhiy.storchaka resolution: fixed stage: patch review -> resolved |
| 2016年04月13日 12:30:01 | python-dev | set | nosy:
+ python-dev messages: + msg263331 |
| 2016年04月12日 20:42:07 | vstinner | set | messages: + msg263276 |
| 2016年04月12日 18:47:29 | serhiy.storchaka | set | files:
+ super_init_leaks_2.patch messages: + msg263270 |
| 2016年04月12日 15:45:28 | vstinner | set | messages: + msg263254 |
| 2016年04月12日 15:43:40 | serhiy.storchaka | set | files:
+ super_init_leaks.patch messages: + msg263253 keywords: + patch type: behavior -> resource usage stage: patch review |
| 2016年04月12日 15:29:03 | vstinner | set | nosy:
+ vstinner |
| 2016年04月12日 15:03:18 | gvanrossum | set | messages: + msg263249 |
| 2016年04月12日 06:31:28 | serhiy.storchaka | set | messages: + msg263232 |
| 2016年04月11日 18:05:41 | gvanrossum | set | status: closed -> open resolution: not a bug -> (no value) messages: + msg263196 |
| 2016年04月11日 18:01:29 | brett.cannon | set | status: open -> closed resolution: not a bug messages: + msg263195 |
| 2016年04月09日 16:28:52 | gvanrossum | set | messages: + msg263103 |
| 2016年04月09日 07:05:47 | serhiy.storchaka | set | nosy:
+ gvanrossum, serhiy.storchaka messages: + msg263073 |
| 2016年04月09日 03:31:37 | SilentGhost | set | nosy:
+ brett.cannon type: behavior versions: + Python 3.5 |
| 2016年04月09日 01:02:03 | Kevin Modzelewski | create | |