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.

Title: memory leaks detected with valgrind for python -V
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vstinner Nosy List: matrixise, vstinner
Priority: normal Keywords: patch

Created on 2019-03-17 23:45 by matrixise, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit
valgrind.log matrixise, 2019-03-17 23:45
valgrind-without-memory-leak.log matrixise, 2019-03-17 23:46
Pull Requests
URL Status Linked Edit
PR 12389 closed matrixise, 2019-03-17 23:49
PR 12400 merged matrixise, 2019-03-18 09:59
PR 12406 merged vstinner, 2019-03-18 12:46
PR 12420 merged vstinner, 2019-03-18 21:00
PR 12432 merged vstinner, 2019-03-19 11:17
Messages (9)
msg338147 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-03-17 23:45
I have detected 3 memory leaks when I execute python -V with valgrind -> 162 bytes.

The leaks do seem to be in pymain_init and in _PyPreConfig_ReadFromArgv (the string for the locale is not freed).

Also _PyRuntimeState_Fini does not release the memory of the mutex on runtime->xidregistry.

You can find the first status in the valgrind.log file (with the leaks).
msg338148 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-03-17 23:46
The report of valgrind with no leaks.
msg338149 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-03-17 23:51
@vstinner I ping you because you are the main author for the new changes in the interpreter and the PyPreConfig part.
msg338185 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-18 09:45
I assign the issue to myself, since I'm currently working on the code: bpo-36301.
msg338191 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-03-18 10:08
I close the PR 12389 because it superseded by PR 12400 (only the fix for _PyRuntimeState_Fini).
msg338288 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-18 21:24
New changeset c183444f7e2640b054956474d71aae6e8d31a543 by Victor Stinner in branch 'master':
bpo-36301: Fix Py_Main() memory leaks (GH-12420)
msg338342 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-19 10:51
New changeset 943395fab925a11ea90d078e771cdfc4443e8c34 by Victor Stinner (Stéphane Wirtel) in branch 'master':
bpo-36333: Fix leak _PyRuntimeState_Fini (GH-12400)
msg338351 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-19 13:19
New changeset a712679a2bffffefaacdc05f788d6ea50f72a561 by Victor Stinner in branch 'master':
bpo-36333, bpo-36356: Fix _PyEval_FiniThreads() (GH-12432)
msg338424 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-19 23:57
"./python -V" no longer leaks, so I close the issue. See bpo-36356 for the follow-up.
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80514
2019-03-19 23:57:14vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg338424

stage: patch review -> resolved
2019-03-19 13:19:43vstinnersetmessages: + msg338351
2019-03-19 11:17:46vstinnersetpull_requests: + pull_request12386
2019-03-19 10:51:35vstinnersetmessages: + msg338342
2019-03-18 21:24:30vstinnersetmessages: + msg338288
2019-03-18 21:00:37vstinnersetpull_requests: + pull_request12375
2019-03-18 12:46:33vstinnersetpull_requests: + pull_request12361
2019-03-18 10:08:48matrixisesetassignee: vstinner
2019-03-18 10:08:25matrixisesetassignee: vstinner -> (no value)
messages: + msg338191
2019-03-18 09:59:39matrixisesetpull_requests: + pull_request12355
2019-03-18 09:45:03vstinnersetassignee: vstinner
messages: + msg338185
2019-03-17 23:51:26matrixisesetnosy: + vstinner
messages: + msg338149
2019-03-17 23:49:15matrixisesetversions: + Python 3.8
2019-03-17 23:49:04matrixisesetkeywords: + patch
stage: patch review
pull_requests: + pull_request12345
2019-03-17 23:46:29matrixisesetfiles: + valgrind-without-memory-leak.log

messages: + msg338148
2019-03-17 23:45:18matrixisecreate