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.

classification
Title: Refleaks in pythonrun.c
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, ocean-city, pitrou, skrah, vstinner
Priority: normal Keywords: patch

Created on 2010-10-20 17:33 by skrah, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py3k_issue10157.patch ocean-city, 2010-10-21 14:49
pythonrun3.patch skrah, 2010-10-23 15:41
Messages (9)
msg119227 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-10-20 17:33
This is one of two remaining "definitely lost" leaks in py3k. It first
appeared in r70152. How to reproduce:

make distclean && ./configure OPT="-O0 -g" --without-pymalloc && make

valgrind --leak-check=full --suppressions=Misc/valgrind-python.supp ./python > VGOUT 2>&1

Then search for 'definitely'. This leak is not present in release-2.7.


==25233== 106 (56 direct, 50 indirect) bytes in 1 blocks are definitely lost in loss record 1,432 of 2,121
==25233==    at 0x4C2412C: malloc (vg_replace_malloc.c:195)
==25233==    by 0x4167AE: _PyObject_New (object.c:243)
==25233==    by 0x42C1C4: _PyUnicode_New (unicodeobject.c:341)
==25233==    by 0x430562: PyUnicodeUCS2_DecodeUTF8Stateful (unicodeobject.c:2036)
==25233==    by 0x430516: PyUnicodeUCS2_DecodeUTF8 (unicodeobject.c:2001)
==25233==    by 0x479F81: r_object (marshal.c:726)
==25233==    by 0x47A03E: r_object (marshal.c:745)
==25233==    by 0x47A720: r_object (marshal.c:873)
==25233==    by 0x47AF4B: PyMarshal_ReadObjectFromString (marshal.c:1053)
==25233==    by 0x47AE2A: PyMarshal_ReadLastObjectFromFile (marshal.c:1012)
==25233==    by 0x471C5B: read_compiled_module (import.c:823)
==25233==    by 0x47230C: load_source_module (import.c:1043)
msg119234 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-10-20 21:14
I tracked it down to r68683, which is still a large commit.
msg119269 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-21 09:08
Your traceback suggests it's a string allocated when reading a module file...
msg119273 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-10-21 11:03
I also thought that it might be a pointer that's lost in marshal.c.
However, perhaps a pointer is lost in Py_Finalize. With this ...

Index: Modules/main.c
===================================================================
--- Modules/main.c      (revision 85766)
+++ Modules/main.c      (working copy)
@@ -697,6 +697,7 @@
         sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
     }
 
+    exit(0);
     Py_Finalize();
 
 #ifdef __INSURE__


... Valgrind does not report the leak.
msg119305 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2010-10-21 14:49
Hello. Does this patch fix the problem?
msg119333 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-10-21 19:48
Hirokazu, the patch looks good to me. Unfortunately Valgrind still
reports the leak.
msg119435 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2010-10-23 15:41
After taking the scenic route through half of the tree[1], I finally
found another leak in pythonrun.c. I'm closing #10153, merging those
two leaks into the new patch.


Does it look ok?


[1] Valgrind stack traces should be approached with caution.
msg119547 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2010-10-25 13:00
I think your patch looks good.
msg119997 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2010-10-30 15:46
Thank you, I committed your patch in r85980(py3k) and
r85981(release31-maint).
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54366
2010-10-30 15:46:46ocean-citysetstatus: open -> closed
versions: + Python 3.1
messages: + msg119997

assignee: ocean-city ->
resolution: fixed
stage: patch review -> resolved
2010-10-25 13:00:05ocean-citysetassignee: ocean-city
messages: + msg119547
2010-10-23 15:43:37skrahlinkissue10153 superseder
2010-10-23 15:41:41skrahsetfiles: + pythonrun3.patch

title: Memory leak (r70152) -> Refleaks in pythonrun.c
messages: + msg119435
stage: patch review
2010-10-21 19:48:17skrahsetmessages: + msg119333
2010-10-21 14:49:58ocean-citysetfiles: + py3k_issue10157.patch

nosy: + ocean-city
messages: + msg119305

keywords: + patch
2010-10-21 11:03:53skrahsetmessages: + msg119273
2010-10-21 09:08:22pitrousetmessages: + msg119269
2010-10-20 21:14:44skrahsetmessages: + msg119234
2010-10-20 17:58:31belopolskysetnosy: + vstinner
2010-10-20 17:34:29skrahsetassignee: amaury.forgeotdarc -> (no value)
2010-10-20 17:33:20skrahcreate