-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
GH-99205: Mark new interpreters and threads as non-static #99268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix an issue that prevented :c:type:`PyThreadState` and | ||
:c:type:`PyInterpreterState` memory from being freed properly. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,6 +356,7 @@ PyInterpreterState_New(void) | |
interp = &runtime->_main_interpreter; | ||
assert(interp->id == 0); | ||
assert(interp->next == NULL); | ||
assert(interp->_static); | ||
|
||
interpreters->main = interp; | ||
} | ||
|
@@ -370,6 +371,9 @@ PyInterpreterState_New(void) | |
// Set to _PyInterpreterState_INIT. | ||
memcpy(interp, &initial._main_interpreter, | ||
sizeof(*interp)); | ||
// We need to adjust any fields that are different from the initial | ||
// interpreter (as defined in _PyInterpreterState_INIT): | ||
interp->_static = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, a note pointing to |
||
|
||
if (id < 0) { | ||
/* overflow or Py_Initialize() not called yet! */ | ||
|
@@ -837,6 +841,7 @@ new_threadstate(PyInterpreterState *interp) | |
assert(id == 1); | ||
used_newtstate = 0; | ||
tstate = &interp->_initial_thread; | ||
assert(tstate->_static); | ||
} | ||
else { | ||
// Every valid interpreter must have at least one thread. | ||
|
@@ -848,6 +853,9 @@ new_threadstate(PyInterpreterState *interp) | |
memcpy(tstate, | ||
&initial._main_interpreter._initial_thread, | ||
sizeof(*tstate)); | ||
// We need to adjust any fields that are different from the initial | ||
// thread (as defined in _PyThreadState_INIT): | ||
tstate->_static = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a note pointing to |
||
} | ||
interp->threads.head = tstate; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.