Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7c9c993

Browse files
GH-99205: Mark new interpreters and threads as non-static (GH-99268)
(cherry picked from commit283ab0e)Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
1 parent014940a commit7c9c993

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an issue that prevented:c:type:`PyThreadState` and
2+
:c:type:`PyInterpreterState` memory from being freed properly.

‎Python/pystate.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ PyInterpreterState_New(void)
341341
interp=&runtime->_main_interpreter;
342342
assert(interp->id==0);
343343
assert(interp->next==NULL);
344+
assert(interp->_static);
344345

345346
interpreters->main=interp;
346347
}
@@ -355,6 +356,9 @@ PyInterpreterState_New(void)
355356
// Set to _PyInterpreterState_INIT.
356357
memcpy(interp,&initial._main_interpreter,
357358
sizeof(*interp));
359+
// We need to adjust any fields that are different from the initial
360+
// interpreter (as defined in _PyInterpreterState_INIT):
361+
interp->_static= false;
358362

359363
if (id<0) {
360364
/* overflow or Py_Initialize() not called yet! */
@@ -817,6 +821,7 @@ new_threadstate(PyInterpreterState *interp)
817821
assert(id==1);
818822
used_newtstate=0;
819823
tstate=&interp->_initial_thread;
824+
assert(tstate->_static);
820825
}
821826
else {
822827
// Every valid interpreter must have at least one thread.
@@ -828,6 +833,9 @@ new_threadstate(PyInterpreterState *interp)
828833
memcpy(tstate,
829834
&initial._main_interpreter._initial_thread,
830835
sizeof(*tstate));
836+
// We need to adjust any fields that are different from the initial
837+
// thread (as defined in _PyThreadState_INIT):
838+
tstate->_static= false;
831839
}
832840
interp->threads.head=tstate;
833841

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp