summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharalampos Stratakis <cstratak@redhat.com>2016-10-14 16:37:19 +0200
committerTim Orling <timothy.t.orling@linux.intel.com>2016-10-14 10:43:32 -0700
commitb6cf0f4b31e461054b1fdbb8ae66c172cb188625 (patch)
tree750640d4491733e4aeb109aa328b7dc6f9767f1a
parent95fa805be59258acc4a3a9330296719b238f79ee (diff)
downloadpython34-el6.tar.gz
python34-el6.tar.xz
python34-el6.zip
Ensure gc tracking is off when invoking weakref callbacksel6
- also correct typos in prior changelog
-rw-r--r--00248-ensure-gc-tracking-is-off-when-invoking-weakref-callbacks.patch87
-rw-r--r--python34.spec17
2 files changed, 101 insertions, 3 deletions
diff --git a/00248-ensure-gc-tracking-is-off-when-invoking-weakref-callbacks.patch b/00248-ensure-gc-tracking-is-off-when-invoking-weakref-callbacks.patch
new file mode 100644
index 0000000..330a6e3
--- /dev/null
+++ b/00248-ensure-gc-tracking-is-off-when-invoking-weakref-callbacks.patch
@@ -0,0 +1,87 @@
+
+# HG changeset patch
+# User Benjamin Peterson <benjamin@python.org>
+# Date 1475564402 25200
+# Node ID c9b7272e25532f84d7feb1b0d942978329156ace
+# Parent b24d0f274623d100e9bad7a4cb1b3f1a3e0b82b1
+ensure gc tracking is off when invoking weakref callbacks (closes #26617)
+
+diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
+--- a/Lib/test/test_weakref.py
++++ b/Lib/test/test_weakref.py
+@@ -845,6 +845,14 @@ class ReferencesTestCase(TestBase):
+ with self.assertRaises(AttributeError):
+ ref1.__callback__ = lambda ref: None
+
++ def test_callback_gcs(self):
++ class ObjectWithDel(Object):
++ def __del__(self): pass
++ x = ObjectWithDel(1)
++ ref1 = weakref.ref(x, lambda ref: support.gc_collect())
++ del x
++ support.gc_collect()
++
+
+ class SubclassableWeakrefTestCase(TestBase):
+
+diff --git a/Objects/typeobject.c b/Objects/typeobject.c
+--- a/Objects/typeobject.c
++++ b/Objects/typeobject.c
+@@ -1123,11 +1123,6 @@ subtype_dealloc(PyObject *self)
+ Py_TRASHCAN_SAFE_BEGIN(self);
+ --_PyTrash_delete_nesting;
+ -- tstate->trash_delete_nesting;
+- /* DO NOT restore GC tracking at this point. weakref callbacks
+- * (if any, and whether directly here or indirectly in something we
+- * call) may trigger GC, and if self is tracked at that point, it
+- * will look like trash to GC and GC will try to delete self again.
+- */
+
+ /* Find the nearest base with a different tp_dealloc */
+ base = type;
+@@ -1138,30 +1133,36 @@ subtype_dealloc(PyObject *self)
+
+ has_finalizer = type->tp_finalize || type->tp_del;
+
+- /* Maybe call finalizer; exit early if resurrected */
+- if (has_finalizer)
++ if (type->tp_finalize) {
+ _PyObject_GC_TRACK(self);
+-
+- if (type->tp_finalize) {
+ if (PyObject_CallFinalizerFromDealloc(self) < 0) {
+ /* Resurrected */
+ goto endlabel;
+ }
+- }
+- /* If we added a weaklist, we clear it. Do this *before* calling
+- tp_del, clearing slots, or clearing the instance dict. */
++ _PyObject_GC_UNTRACK(self);
++ }
++ /*
++ If we added a weaklist, we clear it. Do this *before* calling tp_del,
++ clearing slots, or clearing the instance dict.
++
++ GC tracking must be off at this point. weakref callbacks (if any, and
++ whether directly here or indirectly in something we call) may trigger GC,
++ and if self is tracked at that point, it will look like trash to GC and GC
++ will try to delete self again.
++ */
+ if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
+ PyObject_ClearWeakRefs(self);
+
+ if (type->tp_del) {
++ _PyObject_GC_TRACK(self);
+ type->tp_del(self);
+ if (self->ob_refcnt > 0) {
+ /* Resurrected */
+ goto endlabel;
+ }
++ _PyObject_GC_UNTRACK(self);
+ }
+ if (has_finalizer) {
+- _PyObject_GC_UNTRACK(self);
+ /* New weakrefs could be created during the finalizer call.
+ If this occurs, clear them out without calling their
+ finalizers since they might rely on part of the object
+
diff --git a/python34.spec b/python34.spec
index 46a1586..17b7c7f 100644
--- a/python34.spec
+++ b/python34.spec
@@ -153,7 +153,7 @@
Summary: Version 3 of the Python programming language aka Python 3000
Name: python%{pyshortver}
Version: %{pybasever}.3
-Release: 9%{?dist}
+Release: 10%{?dist}
License: Python
Group: Development/Languages
@@ -784,6 +784,13 @@ Patch241: 00241-CVE-2016-5636-buffer-overflow-in-zipimport-module-fix.patch
# Resolves: rhbz#1359179
Patch242: 00242-CVE-2016-1000110-httpoxy.patch
+# 00248 #
+# Ensure gc tracking is off when invoking weakref callbacks
+# Resolves: rhbz#1384957
+# Backported from python 3.5+
+# FIXED UPSTREAM: http://bugs.python.org/issue26617
+Patch248: 00248-ensure-gc-tracking-is-off-when-invoking-weakref-callbacks.patch
+
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@@ -1072,6 +1079,7 @@ sed -r -i s/'_PIP_VERSION = "[0-9.]+"'/'_PIP_VERSION = "%{pip_version}"'/ Lib/en
%patch238 -p1
%patch241 -p1
%patch242 -p1
+%patch248 -p1
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
@@ -2023,8 +2031,11 @@ rm -fr %{buildroot}
# ======================================================
%changelog
-* Tue Oct 04 2016 Tim Orling <ticotimo@gmal.com> - 3.4.3-9
-- disable test_faulthandler for %{power64}, not just ppc64le
+* Fri Oct 14 2016 Charalampos Stratakis <cstratak@redhat.com> - 3.4.3-10
+- Ensure gc tracking is off when invoking weakref callbacks
+
+* Tue Oct 04 2016 Tim Orling <ticotimo@gmail.com> - 3.4.3-9
+- disable test_faulthandler for %%{power64}, not just ppc64le
* Wed Aug 24 2016 Orion Poplawski <orion@cora.nwra.com> - 3.4.3-8
- Update to build on EL6