cpython/Modules/clinic
Eric Snow 0d5fe2c7b4
[3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425)
_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 81865002ae)
2024-05-22 22:26:58 +00:00
..
_abc.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_asynciomodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_bisectmodule.c.h GH-102833: Mention the key function in the docstrings (GH-103009) 2023-03-25 02:19:20 -05:00
_bz2module.c.h bpo-23224: Fix segfaults and multiple leaks in the lzma and bz2 modules (GH-7822) 2023-02-23 06:00:58 -08:00
_codecsmodule.c.h bpo-15999: Accept arbitrary values for boolean parameters. (#15609) 2022-12-03 11:52:21 -08:00
_collectionsmodule.c.h gh-103092: Isolate _collections (#103093) 2023-04-12 18:21:28 +05:30
_contextvarsmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_cryptmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_csv.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
_curses_panel.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_cursesmodule.c.h bpo-15999: Accept arbitrary values for boolean parameters. (#15609) 2022-12-03 11:52:21 -08:00
_datetimemodule.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
_dbmmodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_elementtree.c.h [3.12] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116248) 2024-03-06 22:01:45 +00:00
_functoolsmodule.c.h gh-64373: Convert _functools to Argument Clinic (#96640) 2022-10-07 10:36:40 -07:00
_gdbmmodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_hashopenssl.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
_heapqmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_localemodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_lsprof.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_lzmamodule.c.h bpo-23224: Fix segfaults and multiple leaks in the lzma and bz2 modules (GH-7822) 2023-02-23 06:00:58 -08:00
_opcode.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
_operator.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_pickle.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_posixsubprocess.c.h gh-94518: Port 23-argument _posixsubprocess.fork_exec to Argument Clinic (#94519) 2023-04-24 18:27:48 +00:00
_queuemodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_randommodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_ssl.c.h gh-101409: Improve generated clinic code for self type checks (#101411) 2023-01-31 21:42:03 +01:00
_statisticsmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_struct.c.h [3.12] gh-112358: Fix Python 3.12 regression with subclassing struct.Struct (GH-112424) (#112426) 2023-11-27 08:25:06 +00:00
_testclinic.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_testinternalcapi.c.h [3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425) 2024-05-22 22:26:58 +00:00
_testmultiphase.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
_tkinter.c.h [3.12] gh-71592: Add ability to trace Tcl commands executed by Tkinter (GH-118291) (GH-118662) 2024-05-06 19:26:08 +00:00
_tracemalloc.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_typingmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_weakref.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
_winapi.c.h gh-90329: Add _winapi.GetLongPathName and GetShortPathName and use in venv to reduce warnings (GH-117817) 2024-04-15 16:43:41 +01:00
_zoneinfo.c.h gh-99138: Isolate _zoneinfo (#99218) 2023-02-15 22:58:48 +01:00
arraymodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
audioop.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
binascii.c.h bpo-15999: Accept arbitrary values for boolean parameters. (#15609) 2022-12-03 11:52:21 -08:00
cmathmodule.c.h Add missing 'is' to cmath.log() docstring (#102049) 2023-02-19 15:00:59 +00:00
fcntlmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
gcmodule.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
grpmodule.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
itertoolsmodule.c.h gh-101277: Finalise isolating itertools (GH-101305) 2023-02-10 03:58:14 -08:00
mathmodule.c.h gh-94906: Support multiple steps in math.nextafter (#103881) 2023-05-19 21:03:49 +01:00
md5module.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
overlapped.c.h gh-98793: Fix typecheck in overlapped.c (#98835) 2022-10-29 21:34:46 -07:00
posixmodule.c.h gh-118507 : Refactor ntpath native functions (gh-119381) 2024-05-22 15:49:26 +01:00
pwdmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
pyexpat.c.h [3.12] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116248) 2024-03-06 22:01:45 +00:00
readline.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
resource.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
selectmodule.c.h gh-101409: Improve generated clinic code for self type checks (#101411) 2023-01-31 21:42:03 +01:00
sha1module.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
sha2module.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00
sha3module.c.h gh-99108: Replace SHA3 implementation HACL* version (#103597) 2023-05-07 20:50:04 -07:00
signalmodule.c.h gh-98930: improve the docstring of signal.strsignal (#99290) 2022-11-13 11:41:23 -08:00
socketmodule.c.h gh-90928: Improve static initialization of keywords tuple in AC (#95907) 2022-08-13 12:09:40 +02:00
spwdmodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
symtablemodule.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
syslogmodule.c.h gh-95011: Migrate syslog module to Argument Clinic (GH-95012) 2022-10-08 21:31:57 +03:00
termios.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
unicodedata.c.h gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (gh-95860) 2022-08-11 15:25:49 -06:00
zlibmodule.c.h [3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067) 2024-02-06 11:20:16 +01:00