Skip to content

bpo-35720: Fixing a memory leak in Modules/main.c:pymain_parse_cmdline_impl#11528

Merged
vstinner merged 1 commit into
python:masterfrom
Lucas-C:pymain_parse_cmdline_impl_memory_leak_fix
Jan 22, 2019
Merged

bpo-35720: Fixing a memory leak in Modules/main.c:pymain_parse_cmdline_impl#11528
vstinner merged 1 commit into
python:masterfrom
Lucas-C:pymain_parse_cmdline_impl_memory_leak_fix

Conversation

@Lucas-C

@Lucas-C Lucas-C commented Jan 11, 2019

Copy link
Copy Markdown
Contributor

When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.

https://bugs.python.org/issue35720

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@Lucas-C

Lucas-C commented Jan 13, 2019

Copy link
Copy Markdown
Contributor Author

The Travis CI build failed with:

The job exceeded the maximum time limit for jobs, and has been terminated.

The Azure Pipeline build failed because of a column in the NEWS entry. I'm removing it:

Warning, treated as error:
[whatsnew/changelog:55] ":pymain" found in "Modules/main.c:pymain_parse_cmdline_impl"

Comment thread Modules/main.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if is useless: PyMem_RawFree(NULL) does nothing, the call is safe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removed

Comment thread Modules/main.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the call after pymain_clear_cmdline() call a few lines before, and leave the comment unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to be unrelated!? cc @aixtools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I included an extra commit by error. This is fixed now

When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @Lucas-C for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 22, 2019
…nGH-11528)

When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv() a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.
(cherry picked from commit 35ca182)

Co-authored-by: Lucas Cimon <lucas.cimon@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-11648 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Jan 22, 2019
)

When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv() a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.
(cherry picked from commit 35ca182)

Co-authored-by: Lucas Cimon <lucas.cimon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants