classification
Title: Memory leak in parsetok
Type: resource usage Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.henrie, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2020-01-11 20:13 by alex.henrie, last changed 2020-01-13 10:54 by miss-islington. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17953 merged alex.henrie, 2020-01-11 20:15
PR 17978 merged miss-islington, 2020-01-13 10:36
PR 17979 closed miss-islington, 2020-01-13 10:36
Messages (3)
msg359821 - (view) Author: Alex Henrie (alex.henrie) * Date: 2020-01-11 20:13
The parsetok function currently contains the following code:

    if (!growable_comment_array_init(&type_ignores, 10)) {
        err_ret->error = E_NOMEM;
        PyTokenizer_Free(tok);
        return NULL;
    }

    if ((ps = PyParser_New(g, start)) == NULL) {
        err_ret->error = E_NOMEM;
        PyTokenizer_Free(tok);
        return NULL;
    }

If PyParser_New fails, there is a memory leak because growable_comment_array_deallocate is not called on type_ignores.
msg359895 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-13 10:35
New changeset 7ba6f18de2582755ae31888ba6a4237d96dddc48 by Pablo Galindo (Alex Henrie) in branch 'master':
bpo-39307: Fix memory leak on error path in parsetok (GH-17953)
https://github.com/python/cpython/commit/7ba6f18de2582755ae31888ba6a4237d96dddc48
msg359896 - (view) Author: miss-islington (miss-islington) Date: 2020-01-13 10:54
New changeset 9671b6b3b3e480fbc4b14aab7008b90b38767f55 by Miss Islington (bot) in branch '3.8':
bpo-39307: Fix memory leak on error path in parsetok (GH-17953)
https://github.com/python/cpython/commit/9671b6b3b3e480fbc4b14aab7008b90b38767f55
History
Date User Action Args
2020-01-13 10:54:27miss-islingtonsetnosy: + miss-islington
messages: + msg359896
2020-01-13 10:36:46pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-13 10:36:16miss-islingtonsetpull_requests: + pull_request17385
2020-01-13 10:36:10miss-islingtonsetpull_requests: + pull_request17384
2020-01-13 10:35:51pablogsalsetmessages: + msg359895
2020-01-13 03:28:04xtreaksetnosy: + pablogsal
2020-01-11 20:15:27alex.henriesetkeywords: + patch
stage: patch review
pull_requests: + pull_request17363
2020-01-11 20:13:33alex.henriecreate