cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-119213: Fix getargs.c to store state in InterpreterState...

Open 1st1 opened this issue 1 year ago • 1 comments

...as opposed to storing it in PyRuntime. Storing it in PyRuntime is fundametally wrong, as its state contains references to Python objects. Those objects (tuples and strings) can (and will) be picked by various subinterpreter clean up code, leaving PyRuntime with broken pointers.

https://github.com/python/cpython/pull/119194 is a backport to 3.12

  • Issue: gh-119213

1st1 avatar May 20 '24 01:05 1st1

How does this work when the _PyArg_Parser instances are themselves declared as static variables (and are global to the process)? For example:

https://github.com/python/cpython/blob/6f7dd0a4260254390d75838c84ccc7285a2264f0/Modules/clinic/_struct.c.h#L49-L53

colesbury avatar May 20 '24 16:05 colesbury

@colesbury, I'm looking into what's going on. Basically, the statically declared tuple is only for builtin modules. I have a solution that's different from Yury's but want to be sure it's correct before closing this one.

ericsnowcurrently avatar May 21 '24 13:05 ericsnowcurrently

superseded by gh-119331

ericsnowcurrently avatar May 22 '24 21:05 ericsnowcurrently