bpo-37926: Fix PySys_SetArgvEx(0, NULL, 0)#15415
Conversation
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.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
Sorry, @vstinner, I could not cleanly backport this to |
|
Does this need backport to 3.7? The issue says 3.7 and 3.8 |
|
I'm working on a backport to 3.8. |
|
GH-15420 is a backport of this pull request to the 3.8 branch. |
Python 3.7 is not affected: it uses "static wchar_t *empty_argv[1] = {L""};". |
|
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) |
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)
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.
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.
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.
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