[issue11826] Leak in atexitmodule
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 7c48bb929e6e by Stefan Krah in branch 'default': Issue #11826: Fix memory leak in atexitmodule. http://hg.python.org/cpython/rev/7c48bb929e6e -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
Changes by Stefan Krah stefan-use...@bytereef.org: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed versions: -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
Stefan Krah stefan-use...@bytereef.org added the comment: Actually _iomodule.c already has a freefunc with the same signature. atexit_free() is properly called in: static void module_dealloc(PyModuleObject *m) { PyObject_GC_UnTrack(m); if (m-md_def m-md_def-m_free) m-md_def-m_free(m); if (m-md_dict != NULL) { _PyModule_Clear((PyObject *)m); Py_DECREF(m-md_dict); } if (m-md_state != NULL) PyMem_FREE(m-md_state); Py_TYPE(m)-tp_free((PyObject *)m); } So my only worry is if there's a way to exploit the fact that _PyModule_Clear() is called after atexit_free(). I tried things like: import atexit def g(): pass ... class silly: ... def __del__(self): atexit.register(g) ... atexit.x = silly() atexit.register(g) function g at 0x7fe7ebb83a68 Exception AttributeError: 'NoneType' object has no attribute 'register' in bound method silly.__del__ of __main__.silly object at 0x153fc50 ignored But I haven't been able to break anything, so I think I'll go ahead and commit if there aren't any protests. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
Stefan Krah stefan-use...@bytereef.org added the comment: Antoine Pitrou rep...@bugs.python.org wrote: Well, if it doesn't crash, it's probably ok ;) Perhaps check modstate-atexit_callbacks for non-NULL? Or do we trust free() to do the right thing? I was initially surprised by this, but the docs state that it's safe: http://docs.python.org/dev/c-api/memory.html?highlight=pymem_free#PyMem_Free The I searched a bit and it appears that free() crashing on NULL is a pre-ANSI thing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
Antoine Pitrou pit...@free.fr added the comment: Well, if it doesn't crash, it's probably ok ;) Perhaps check modstate-atexit_callbacks for non-NULL? Or do we trust free() to do the right thing? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: It's the very first usage of PyModuleDef::m_free. Martin, do you agree with the path? -- nosy: +amaury.forgeotdarc, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11826] Leak in atexitmodule
New submission from Stefan Krah stefan-use...@bytereef.org: Valgrind reports a leak (definitely lost) in atexitmodule.c. The patch fixes the problem. -- components: Extension Modules files: atexit-leak.patch keywords: patch messages: 133501 nosy: skrah priority: normal severity: normal stage: patch review status: open title: Leak in atexitmodule type: resource usage versions: Python 3.2, Python 3.3 Added file: http://bugs.python.org/file21610/atexit-leak.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com