summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-22 18:09:48 (GMT)
committerGitHub <noreply@github.com>2024-05-22 18:09:48 (GMT)
commitbfd9c3ea5336f2898e3c58e0c3999bfc25d7da89 (patch)
tree9ac0fd005fe5c7754cbb9250518afed10dbfa79b /Misc
parenta463cd8e45d6fc6ca16a59bcfeece99cf268e684 (diff)
downloadcpython-bfd9c3ea5336f2898e3c58e0c3999bfc25d7da89.zip
cpython-bfd9c3ea5336f2898e3c58e0c3999bfc25d7da89.tar.gz
cpython-bfd9c3ea5336f2898e3c58e0c3999bfc25d7da89.tar.bz2
[3.13] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119410)
_PyArg_Parser holds static global data generated for modules by Argument Clinic. The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global. In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters. However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed. This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes. It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime. The solution here is to temporarily switch to the main interpreter. The alternative would be to always statically allocate the tuple. This change also fixes a bug where only the most recent parser was added to the global linked list. (cherry picked from commit 81865002aee8eaaeb3c7e402f86183afa6de77bf) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2024-05-21-11-27-14.gh-issue-119213.nxjxrt.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-05-21-11-27-14.gh-issue-119213.nxjxrt.rst b/Misc/NEWS.d/next/Core and Builtins/2024-05-21-11-27-14.gh-issue-119213.nxjxrt.rst
new file mode 100644
index 0000000..e9073b4
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2024-05-21-11-27-14.gh-issue-119213.nxjxrt.rst
@@ -0,0 +1,3 @@
+Non-builtin modules built with argument clinic were crashing if used in a
+subinterpreter before the main interpreter. The objects that were causing
+the problem by leaking between interpreters carelessly have been fixed.