Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ struct _is {
int finalizing;

struct _ceval_state ceval;
// bpo-46070: Even if each PyInterpreterState has a GC state,
// _PyGC_GetState() only uses the state of the main interpreter.
struct _gc_runtime_state gc;

PyObject *modules;
Expand Down
14 changes: 12 additions & 2 deletions 14 Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
/* Only private in Python 3.10 and 3.9.8+; public in 3.11 */
extern PyObject *_PyType_GetQualName(PyTypeObject *type);

static inline struct _gc_runtime_state*
_PyGC_GetState(void)
{
// bpo-46070: Even if each PyInterpreterState has a GC state,
// _PyGC_GetState() only uses the state of the main interpreter.
PyInterpreterState *interp = _PyRuntime.interpreters.main;
return &interp->gc;
}


/* Tell the GC to track this object.
*
* NB: While the object is tracked by the collector, it must be safe to call the
Expand All @@ -42,8 +52,8 @@ static inline void _PyObject_GC_TRACK_impl(const char *filename, int lineno,
"object is in generation which is garbage collected",
filename, lineno, "_PyObject_GC_TRACK");

PyThreadState *tstate = _PyThreadState_GET();
PyGC_Head *generation0 = tstate->interp->gc.generation0;
struct _gc_runtime_state *state = _PyGC_GetState();
PyGC_Head *generation0 = state->generation0;
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
_PyGCHead_SET_NEXT(last, gc);
_PyGCHead_SET_PREV(gc, last);
Expand Down
6 changes: 3 additions & 3 deletions 6 Include/internal/pycore_pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
extern PyStatus _PyTypes_Init(void);
extern PyStatus _PyTypes_InitSlotDefs(void);
extern PyStatus _PyImportZip_Init(PyThreadState *tstate);
extern PyStatus _PyGC_Init(PyThreadState *tstate);
extern PyStatus _PyGC_Init(void);


/* Various internal finalizers */
Expand All @@ -74,7 +74,7 @@ extern void PyOS_FiniInterrupts(void);
extern void _PyExc_Fini(void);
extern void _PyImport_Fini(void);
extern void _PyImport_Fini2(void);
extern void _PyGC_Fini(PyThreadState *tstate);
extern void _PyGC_Fini(void);
extern void _PyType_Fini(void);
extern void _Py_HashRandomization_Fini(void);
extern void _PyUnicode_Fini(PyThreadState *tstate);
Expand All @@ -88,7 +88,7 @@ extern void _PyAST_Fini(void);
extern PyStatus _PyGILState_Init(PyThreadState *tstate);
extern void _PyGILState_Fini(PyThreadState *tstate);

PyAPI_FUNC(void) _PyGC_DumpShutdownStats(PyThreadState *tstate);
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);

PyAPI_FUNC(PyStatus) _Py_PreInitializeFromPyArgv(
const PyPreConfig *src_config,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a random crash involving subinterpreters on Windows. Revert the change
which made the gc module state per interpreter: the gc module state is
shared again by all interpreters. Patch by Victor Stinner.
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.