summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python')
-rw-r--r--meta/recipes-devtools/python/python3/0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch54
-rw-r--r--meta/recipes-devtools/python/python3_3.10.4.bb1
2 files changed, 55 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3/0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch b/meta/recipes-devtools/python/python3/0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch
new file mode 100644
index 0000000000..6a58c35cc6
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch
@@ -0,0 +1,54 @@
1From 178a238f25ab8aff7689d7a09d66dc1583ecd6cb Mon Sep 17 00:00:00 2001
2From: "Miss Islington (bot)"
3 <31488909+miss-islington@users.noreply.github.com>
4Date: Wed, 4 May 2022 03:23:29 -0700
5Subject: [PATCH 01/40] gh-92036: Fix gc_fini_untrack() (GH-92037)
6
7Fix a crash in subinterpreters related to the garbage collector. When
8a subinterpreter is deleted, untrack all objects tracked by its GC.
9To prevent a crash in deallocator functions expecting objects to be
10tracked by the GC, leak a strong reference to these objects on
11purpose, so they are never deleted and their deallocator functions
12are not called.
13(cherry picked from commit 14243369b5f80613628a565c224bba7fb3fcacd8)
14
15Co-authored-by: Victor Stinner <vstinner@python.org>
16
17Upstream-Status: Backport
18---
19 .../2022-04-28-23-37-30.gh-issue-92036.GZJAC9.rst | 5 +++++
20 Modules/gcmodule.c | 6 ++++++
21 2 files changed, 11 insertions(+)
22 create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-04-28-23-37-30.gh-issue-92036.GZJAC9.rst
23
24diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-28-23-37-30.gh-issue-92036.GZJAC9.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-28-23-37-30.gh-issue-92036.GZJAC9.rst
25new file mode 100644
26index 0000000000..78094c5e4f
27--- /dev/null
28+++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-28-23-37-30.gh-issue-92036.GZJAC9.rst
29@@ -0,0 +1,5 @@
30+Fix a crash in subinterpreters related to the garbage collector. When a
31+subinterpreter is deleted, untrack all objects tracked by its GC. To prevent a
32+crash in deallocator functions expecting objects to be tracked by the GC, leak
33+a strong reference to these objects on purpose, so they are never deleted and
34+their deallocator functions are not called. Patch by Victor Stinner.
35diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
36index 805a159d53..43ae6fa98b 100644
37--- a/Modules/gcmodule.c
38+++ b/Modules/gcmodule.c
39@@ -2170,6 +2170,12 @@ gc_fini_untrack(PyGC_Head *list)
40 for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(list)) {
41 PyObject *op = FROM_GC(gc);
42 _PyObject_GC_UNTRACK(op);
43+ // gh-92036: If a deallocator function expect the object to be tracked
44+ // by the GC (ex: func_dealloc()), it can crash if called on an object
45+ // which is no longer tracked by the GC. Leak one strong reference on
46+ // purpose so the object is never deleted and its deallocator is not
47+ // called.
48+ Py_INCREF(op);
49 }
50 }
51
52--
532.25.1
54
diff --git a/meta/recipes-devtools/python/python3_3.10.4.bb b/meta/recipes-devtools/python/python3_3.10.4.bb
index 357025f856..34fd2895a3 100644
--- a/meta/recipes-devtools/python/python3_3.10.4.bb
+++ b/meta/recipes-devtools/python/python3_3.10.4.bb
@@ -35,6 +35,7 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
35 file://0001-setup.py-Do-not-detect-multiarch-paths-when-cross-co.patch \ 35 file://0001-setup.py-Do-not-detect-multiarch-paths-when-cross-co.patch \
36 file://deterministic_imports.patch \ 36 file://deterministic_imports.patch \
37 file://0001-Avoid-shebang-overflow-on-python-config.py.patch \ 37 file://0001-Avoid-shebang-overflow-on-python-config.py.patch \
38 file://0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch \
38 " 39 "
39 40
40SRC_URI:append:class-native = " \ 41SRC_URI:append:class-native = " \