[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Roundup Robot added the comment: New changeset 30925a3b2324 by Benjamin Peterson in branch '3.4': fix potential refleak in PyFloat_AsDouble (closes #23590) https://hg.python.org/cpython/rev/30925a3b2324 New changeset f31b91b6683a by Benjamin Peterson in branch '2.7': fix potential refleak in PyFloat_AsDouble (closes #23590) https://hg.python.org/cpython/rev/f31b91b6683a New changeset 4d9594018edd by Benjamin Peterson in branch 'default': merge 3.4 (#23590) https://hg.python.org/cpython/rev/4d9594018edd -- nosy: +python-dev resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Mark Dickinson added the comment: Thanks, Benjamin! -- assignee: mark.dickinson - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Mark Dickinson added the comment: Patch LGTM. Marking as high priority. -- nosy: +mark.dickinson priority: normal - high ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Mark Dickinson added the comment: The patch should have a test before it goes in. As an aside, it's a bit disturbing that we apparently don't have any code already in our test-suite that exercises this case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Changes by Antoine Pitrou pit...@free.fr: -- stage: - patch review type: behavior - resource usage versions: +Python 2.7, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Patrick Miller added the comment: This is also in the 2.7.x branch. Same patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Patrick Miller added the comment: Here's a simple recreator... It returns a 100-meg string instead of a float. The memory is leaked each time through the loop -- Added file: http://bugs.python.org/file38343/recreate.tar ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Patrick Miller added the comment: Shout out to amaury for a much simpler recreator :-) Checked to see if the int conversion suffered the same problem... it does not as it is structured somewhat differently. Note that it DOES do the proper DECREF (missing in PyFloat_AsDouble). result = nb-nb_int(integral); if (!result || PyLong_CheckExact(result)) return (PyLongObject *)result; if (!PyLong_Check(result)) { PyErr_Format(PyExc_TypeError, __int__ returned non-int (type %.200s), result-ob_type-tp_name); Py_DECREF(result); return NULL; } -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
Amaury Forgeot d'Arc added the comment: Simple script to reproduce the issue: import sys, time class C(object): def __float__(self): return for x in range(1): try: time.sleep(C()) except TypeError: pass if x % 1000 == 0: print(sys.getrefcount()) -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23590] Potential leak in PyFloat_AsDouble. Refcount error.
New submission from Patrick Miller: There is a reference counting error in PyFloat_AsDouble. When the function calls the nb_float conversion, if the method does not return an actual float object, an exception is set, but the object is not collected. --- Objects/floatobject.c 2014-10-08 04:18:15.0 -0400 +++ Objects/floatobject.c.patched 2015-03-05 09:17:15.171455648 -0500 @@ -214,6 +214,7 @@ if (fo == NULL) return -1; if (!PyFloat_Check(fo)) { +Py_DECREF(fo); PyErr_SetString(PyExc_TypeError, nb_float should return float object); return -1; -- components: Interpreter Core files: floatobject.c-patch messages: 237266 nosy: Patrick Miller priority: normal severity: normal status: open title: Potential leak in PyFloat_AsDouble. Refcount error. type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file38342/floatobject.c-patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23590 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com