diff options
author | fuzzard <fuzzard@kodi.tv> | 2022-11-11 08:09:23 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2022-11-11 08:09:23 +1000 |
commit | 859405e9e34d05701a9b14f06c54d330ef7eb2e7 (patch) | |
tree | 2d59f515fb3649b67eb17dd38c95bf21569006c9 /tools | |
parent | 31ceec99b6fabec3c12a9a48c2266b2b92225089 (diff) |
[tools/depends][python3] Patch upstream issue memleak
A memleak was found in cpython 3.11.0 that looks to potentially be reasonably serious
Upstream issue is https://github.com/python/cpython/issues/99205
This uses the merged upstream patch https://github.com/python/cpython/pull/99301
until we bump to a newer release (3.11.1+)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/depends/target/python3/01-fix-memleak-PR99301.patch | 38 | ||||
-rw-r--r-- | tools/depends/target/python3/Makefile | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tools/depends/target/python3/01-fix-memleak-PR99301.patch b/tools/depends/target/python3/01-fix-memleak-PR99301.patch new file mode 100644 index 0000000000..63ed86fb7b --- /dev/null +++ b/tools/depends/target/python3/01-fix-memleak-PR99301.patch @@ -0,0 +1,38 @@ +--- a/Python/pystate.c ++++ b/Python/pystate.c +@@ -341,6 +341,7 @@ PyInterpreterState_New(void) + interp = &runtime->_main_interpreter; + assert(interp->id == 0); + assert(interp->next == NULL); ++ assert(interp->_static); + + interpreters->main = interp; + } +@@ -355,6 +356,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; + + if (id < 0) { + /* overflow or Py_Initialize() not called yet! */ +@@ -817,6 +821,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. +@@ -828,6 +833,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; + } + interp->threads.head = tstate; + diff --git a/tools/depends/target/python3/Makefile b/tools/depends/target/python3/Makefile index d6b427e35a..840f7ea12e 100644 --- a/tools/depends/target/python3/Makefile +++ b/tools/depends/target/python3/Makefile @@ -3,6 +3,7 @@ DEPS = ../../Makefile.include Makefile PYTHON3-VERSION ../../download-files.incl apple.patch \ crosscompile.patch \ darwin_embedded.patch \ + 01-fix-memleak-PR99301.patch \ 10-android-modules.patch \ 10-linux-modules.patch \ 10-osx-modules.patch \ @@ -56,6 +57,9 @@ all: .installed-$(PLATFORM) $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) $(DEPS) rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) +# Temp patch to resolve https://github.com/python/cpython/issues/99205 +# Remove in 3.11.1+ bump + cd $(PLATFORM); patch -p1 -i ../01-fix-memleak-PR99301.patch cd $(PLATFORM); patch -p1 -i ../crosscompile.patch cd $(PLATFORM); patch -p1 -i ../apple.patch ifeq ($(OS),darwin_embedded) |