Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-37926: Fix PySys_SetArgvEx(0, NULL, 0) #15415

Merged
merged 1 commit into from
Aug 23, 2019
Merged

bpo-37926: Fix PySys_SetArgvEx(0, NULL, 0) #15415

merged 1 commit into from
Aug 23, 2019

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Aug 23, 2019

empty_argv is no longer static in Python 3.8, but it was declared in
a temporary scope, whereas argv kept a reference to it. Define
empty_argv in PySys_SetArgvEx() body, to ensure that it remains valid
for the whole lifetime of the PySys_SetArgvEx() call.

Previously, empty_argv memory (allocated on the stack) was reused by
make_sys_argv() code which is inlined when using gcc -O3.

https://bugs.python.org/issue37926

empty_argv is no longer static in Python 3.8, but it was declared in
a temporary scope, whereas argv kept a reference to it. Define
empty_argv in PySys_SetArgvEx() body, to ensure that it remains valid
for the whole lifetime of the PySys_SetArgvEx() call.

Previously, empty_argv memory (allocated on the stack) was reused by
make_sys_argv() code which is inlined when using gcc -O3.
@vstinner vstinner merged commit c486825 into python:master Aug 23, 2019
@vstinner vstinner deleted the pysys_setargvex branch August 23, 2019 10:04
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker c48682509dc49b43fe914fe6c502bc390345d1c2 3.8

@pablogsal
Copy link
Member

Does this need backport to 3.7? The issue says 3.7 and 3.8

@vstinner
Copy link
Member Author

I'm working on a backport to 3.8.

@bedevere-bot
Copy link

GH-15420 is a backport of this pull request to the 3.8 branch.

@vstinner
Copy link
Member Author

Does this need backport to 3.7? The issue says 3.7 and 3.8

Python 3.7 is not affected: it uses "static wchar_t *empty_argv[1] = {L""};".

@vstinner
Copy link
Member Author

Moreover, the issue says "This works in 3.7 but no longer does in 3.8" :-)

@pablogsal
Copy link
Member

pablogsal commented Aug 23, 2019

Moreover, the issue says "This works in 3.7 but no longer does in 3.8" :-)

Sorry, I just need more coffee ☕️ (Rode "between Python 3.7 and 3.8" and registered 3.7 and 3.8)

vstinner added a commit that referenced this pull request Aug 23, 2019
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.

Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.

(cherry picked from commit c486825)
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.

Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.

Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.

Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.
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