diff options
| author | Markus Volk <f_l_k@t-online.de> | 2022-07-04 15:21:41 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-07-25 15:11:46 +0100 |
| commit | 8fa95bb5991e2b7f104366b5dd53551f190919bb (patch) | |
| tree | d1b9f08f21ec9f54cf16f4ec6f5027ef8ad7a05e /meta/recipes-devtools/python/python3 | |
| parent | 66f67f397e1b17529c5677128b9422d7f3228781 (diff) | |
| download | poky-8fa95bb5991e2b7f104366b5dd53551f190919bb.tar.gz | |
python3: Backport patch to fix an issue in subinterpreters
This adds a backport patch that fixes a problem in subinterpreters related
to the garbagecollector. Without the patch, there are random segfaults in
several Kodi addons that use python3-sqlite3. Presumably there are real world
issues in other programs as well.
(From OE-Core rev: 39d57ef7e341a048b94bc5dd9c29d58f57e06f19)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python3')
| -rw-r--r-- | meta/recipes-devtools/python/python3/0001-gh-92036-Fix-gc_fini_untrack-GH-92037.patch | 54 |
1 files changed, 54 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 @@ | |||
| 1 | From 178a238f25ab8aff7689d7a09d66dc1583ecd6cb Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "Miss Islington (bot)" | ||
| 3 | <31488909+miss-islington@users.noreply.github.com> | ||
| 4 | Date: Wed, 4 May 2022 03:23:29 -0700 | ||
| 5 | Subject: [PATCH 01/40] gh-92036: Fix gc_fini_untrack() (GH-92037) | ||
| 6 | |||
| 7 | Fix a crash in subinterpreters related to the garbage collector. When | ||
| 8 | a subinterpreter is deleted, untrack all objects tracked by its GC. | ||
| 9 | To prevent a crash in deallocator functions expecting objects to be | ||
| 10 | tracked by the GC, leak a strong reference to these objects on | ||
| 11 | purpose, so they are never deleted and their deallocator functions | ||
| 12 | are not called. | ||
| 13 | (cherry picked from commit 14243369b5f80613628a565c224bba7fb3fcacd8) | ||
| 14 | |||
| 15 | Co-authored-by: Victor Stinner <vstinner@python.org> | ||
| 16 | |||
| 17 | Upstream-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 | |||
| 24 | diff --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 | ||
| 25 | new file mode 100644 | ||
| 26 | index 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. | ||
| 35 | diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c | ||
| 36 | index 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 | -- | ||
| 53 | 2.25.1 | ||
| 54 | |||
