| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -356,6 +356,7 @@ PyInterpreterState_New(void) | |||
| 356 | 356 | interp = &runtime->_main_interpreter; | |
| 357 | 357 | assert(interp->id == 0); | |
| 358 | 358 | assert(interp->next == NULL); | |
| 359 | + assert(interp->_static); | ||
| 359 | 360 | ||
| 360 | 361 | interpreters->main = interp; | |
| 361 | 362 | } | |
@@ -370,6 +371,9 @@ PyInterpreterState_New(void) | |||
| 370 | 371 | // Set to _PyInterpreterState_INIT. | |
| 371 | 372 | memcpy(interp, &initial._main_interpreter, | |
| 372 | 373 | sizeof(*interp)); | |
| 374 | + // We need to adjust any fields that are different from the initial | ||
| 375 | + // interpreter (as defined in _PyInterpreterState_INIT): | ||
| 376 | + interp->_static = false; | ||
| 373 | 377 | ||
| 374 | 378 | if (id < 0) { | |
| 375 | 379 | /* overflow or Py_Initialize() not called yet! */ | |
@@ -837,6 +841,7 @@ new_threadstate(PyInterpreterState *interp) | |||
| 837 | 841 | assert(id == 1); | |
| 838 | 842 | used_newtstate = 0; | |
| 839 | 843 | tstate = &interp->_initial_thread; | |
| 844 | + assert(tstate->_static); | ||
| 840 | 845 | } | |
| 841 | 846 | else { | |
| 842 | 847 | // Every valid interpreter must have at least one thread. | |
@@ -848,6 +853,9 @@ new_threadstate(PyInterpreterState *interp) | |||
| 848 | 853 | memcpy(tstate, | |
| 849 | 854 | &initial._main_interpreter._initial_thread, | |
| 850 | 855 | sizeof(*tstate)); | |
| 856 | + // We need to adjust any fields that are different from the initial | ||
| 857 | + // thread (as defined in _PyThreadState_INIT): | ||
| 858 | + tstate->_static = false; | ||
| 851 | 859 | } | |
| 852 | 860 | interp->threads.head = tstate; | |
| 853 | 861 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments