| 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 | |
|---|---|---|---|
@@ -341,6 +341,7 @@ PyInterpreterState_New(void) | |||
| 341 | 341 | interp = &runtime->_main_interpreter; | |
| 342 | 342 | assert(interp->id == 0); | |
| 343 | 343 | assert(interp->next == NULL); | |
| 344 | + assert(interp->_static); | ||
| 344 | 345 | ||
| 345 | 346 | interpreters->main = interp; | |
| 346 | 347 | } | |
@@ -355,6 +356,9 @@ PyInterpreterState_New(void) | |||
| 355 | 356 | // Set to _PyInterpreterState_INIT. | |
| 356 | 357 | memcpy(interp, &initial._main_interpreter, | |
| 357 | 358 | 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; | ||
| 358 | 362 | ||
| 359 | 363 | if (id < 0) { | |
| 360 | 364 | /* overflow or Py_Initialize() not called yet! */ | |
@@ -817,6 +821,7 @@ new_threadstate(PyInterpreterState *interp) | |||
| 817 | 821 | assert(id == 1); | |
| 818 | 822 | used_newtstate = 0; | |
| 819 | 823 | tstate = &interp->_initial_thread; | |
| 824 | + assert(tstate->_static); | ||
| 820 | 825 | } | |
| 821 | 826 | else { | |
| 822 | 827 | // Every valid interpreter must have at least one thread. | |
@@ -828,6 +833,9 @@ new_threadstate(PyInterpreterState *interp) | |||
| 828 | 833 | memcpy(tstate, | |
| 829 | 834 | &initial._main_interpreter._initial_thread, | |
| 830 | 835 | 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; | ||
| 831 | 839 | } | |
| 832 | 840 | interp->threads.head = tstate; | |
| 833 | 841 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments