cpython/Tools/clinic/libclinic
Eric Snow 81865002ae
gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331)
_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.
2024-05-22 09:57:52 -06:00
..
__init__.py gh-113317: Argument Clinic: Add libclinic.converters module (#117315) 2024-04-02 10:09:53 +00:00
app.py gh-113317: Add ParseArgsCodeGen class (#117707) 2024-04-11 13:49:07 +00:00
block_parser.py gh-113317, AC: Add libclinic.block_parser module (#116819) 2024-03-14 16:11:39 +00:00
clanguage.py gh-113317: Add ParseArgsCodeGen class (#117707) 2024-04-11 13:49:07 +00:00
cli.py gh-113317: Finish splitting Argument Clinic into sub-files (#117513) 2024-04-04 11:09:40 +02:00
codegen.py gh-113317: Add ParseArgsCodeGen class (#117707) 2024-04-11 13:49:07 +00:00
converter.py gh-113317: Add Codegen class to Argument Clinic (#117626) 2024-04-11 12:15:48 +02:00
converters.py gh-113317: Add Codegen class to Argument Clinic (#117626) 2024-04-11 12:15:48 +02:00
cpp.py gh-113299: Move cpp.py into libclinic (#113526) 2023-12-28 00:20:57 +01:00
dsl_parser.py gh-117613: Argument Clinic: disallow defining class parameter at module level (#117950) 2024-04-17 22:43:29 +02:00
errors.py gh-113317, AC: Move warn() and fail() to libclinic.errors (#116770) 2024-03-14 08:07:01 +00:00
formatting.py gh-113317: Argument Clinic: move linear_format into libclinic (#115518) 2024-02-15 23:52:20 +01:00
function.py gh-117431: Argument Clinic: copy forced text signature when cloning (#117591) 2024-04-10 10:12:05 +02:00
identifiers.py gh-113317: Argument Clinic: move C/Py identifier helpers into libclinic (#115520) 2024-02-16 07:42:15 +01:00
language.py gh-113317: Finish splitting Argument Clinic into sub-files (#117513) 2024-04-04 11:09:40 +02:00
parse_args.py gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) 2024-05-22 09:57:52 -06:00
parser.py gh-113317: Finish splitting Argument Clinic into sub-files (#117513) 2024-04-04 11:09:40 +02:00
return_converters.py gh-113317: Add Codegen class to Argument Clinic (#117626) 2024-04-11 12:15:48 +02:00
utils.py gh-113317: Argument Clinic: Add libclinic.converters module (#117315) 2024-04-02 10:09:53 +00:00