Issue 15893: Py_FrozenMain() resource leak and missing malloc checks (original) (raw)

Created on 2012-09-09 22:09 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-15893-01.patch thomaslee,2012-09-16 04:42 review
Messages (9)
msg170139 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-09-09 22:09
In Python/frozenmain.c the function Py_FrozenMain() doesn't handle argv_copy and argv_copy2 correctly. Both variables contain memory that is allocated with PyMem_Malloc(). argv_copy2 is never checked for NULL and both variables are not correctly cleaned up in error cases. CID 486834: Resource leak (RESOURCE_LEAK)At (11): Variable "argv_copy" going out of scope leaks the storage it points to. CID 486835: Resource leak (RESOURCE_LEAK)At (9): Variable "argv_copy2" going out of scope leaks the storage it points to. Suggested fix: Separate var declaration from PyMem_Malloc() calls and use a goto label to clean up the variables and its content at the end of the function.
msg170547 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2012-09-16 04:42
Patch against hg tip attached.
msg193763 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-26 23:06
New changeset ab8121466785 by Victor Stinner in branch '3.3': Issue #15893: frozenmain.c now handles PyMem_Malloc() failure http://hg.python.org/cpython/rev/ab8121466785 New changeset 386ab2c12301 by Victor Stinner in branch 'default': (Merge 3.3) Issue #15893: frozenmain.c now handles PyMem_Malloc() failure http://hg.python.org/cpython/rev/386ab2c12301
msg193767 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-27 00:39
New changeset 47c6aa17fd90 by Victor Stinner in branch 'default': Issue #15893: Improve error handling in main() and Py_FrozenMain() http://hg.python.org/cpython/rev/47c6aa17fd90
msg193768 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-27 00:42
New changeset 12af9db5212a by Victor Stinner in branch '3.3': Issue #15893: Remove dead code http://hg.python.org/cpython/rev/12af9db5212a
msg193769 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-07-27 00:43
I didn't know Py_FrozenMain(). I upgraded it to use the same code than main(). Should I backport my fixes to Python 3.3 (except maybe 0001c4100823 which is risky).
msg200725 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-10-21 08:56
Victor, is here anything left to do?
msg214535 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-03-23 01:51
This believe that this can be closed as Python 3.3 is no longer taking fixes.
msg214558 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-03-23 10:00
> Victor, is here anything left to do? The bug is correctly fixed in default. I don't really care of fixing such warning of static analyzer in older Python versions. It's more a theorical bug, it's a small memory leak and only occur if another error occurs. I just close the issue.
History
Date User Action Args
2022-04-11 14:57:35 admin set github: 60097
2014-03-23 10:00:53 vstinner set status: languishing -> closedresolution: fixedmessages: +
2014-03-23 01:51:58 BreamoreBoy set nosy: + BreamoreBoymessages: +
2013-10-21 08:56:13 christian.heimes set status: open -> languishingassignee: vstinnermessages: + stage: commit review
2013-07-27 00:43:49 vstinner set nosy: + vstinnermessages: +
2013-07-27 00:42:08 python-dev set messages: +
2013-07-27 00:39:51 python-dev set messages: +
2013-07-26 23:06:01 python-dev set nosy: + python-devmessages: +
2012-09-16 04:42:04 thomaslee set files: + issue-15893-01.patchnosy: + thomasleemessages: + keywords: + patch
2012-09-10 02:25:56 jcea set nosy: + jcea
2012-09-09 22:09:57 christian.heimes create